2024-12-23 04:56:38 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public static class MaterialChecker
|
|
|
|
|
{
|
|
|
|
|
[MenuItem("Tools/Check Materials in Selected Object")]
|
|
|
|
|
private static void CheckSelectedObject()
|
|
|
|
|
{
|
2025-03-24 23:40:25 +00:00
|
|
|
// 현재 선택된 오브젝트 가져오기
|
2024-12-23 04:56:38 +00:00
|
|
|
GameObject selectedObject = Selection.activeGameObject;
|
|
|
|
|
|
|
|
|
|
if (selectedObject == null)
|
|
|
|
|
{
|
2025-01-06 01:42:06 +00:00
|
|
|
Debug.LogWarning("오브젝트를 선택하세요.");
|
2024-12-23 04:56:38 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-24 23:40:25 +00:00
|
|
|
// 자식 포함 MeshRenderer 가져오기
|
2024-12-23 04:56:38 +00:00
|
|
|
MeshRenderer[] meshRenderers = selectedObject.GetComponentsInChildren<MeshRenderer>();
|
|
|
|
|
if (meshRenderers.Length == 0)
|
|
|
|
|
{
|
2025-01-06 01:42:06 +00:00
|
|
|
Debug.Log($"'{selectedObject.name}'에는 MeshRenderer가 포함된 자식 오브젝트가 없습니다.");
|
2024-12-23 04:56:38 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-24 23:40:25 +00:00
|
|
|
// 고유한 매터리얼 저장용 HashSet
|
2024-12-23 04:56:38 +00:00
|
|
|
HashSet<Material> uniqueMaterials = new HashSet<Material>();
|
|
|
|
|
foreach (var renderer in meshRenderers)
|
|
|
|
|
{
|
|
|
|
|
foreach (var material in renderer.sharedMaterials)
|
|
|
|
|
{
|
|
|
|
|
if (material != null)
|
|
|
|
|
{
|
|
|
|
|
uniqueMaterials.Add(material);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-24 23:40:25 +00:00
|
|
|
// 결과 출력
|
2025-01-06 01:42:06 +00:00
|
|
|
Debug.Log($"'{selectedObject.name}'에 사용된 고유한 매터리얼 수: {uniqueMaterials.Count}");
|
2024-12-23 04:56:38 +00:00
|
|
|
int i = 0;
|
|
|
|
|
foreach (var material in uniqueMaterials)
|
|
|
|
|
{
|
2025-03-24 23:40:25 +00:00
|
|
|
string path = AssetDatabase.GetAssetPath(material); // 매터리얼 경로
|
|
|
|
|
Debug.Log($"{i++} : {material.name} (Path: {path})", material);
|
2024-12-23 04:56:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
2025-01-06 01:42:06 +00:00
|
|
|
|
|
|
|
|
[MenuItem("Tools/Remove Specific Components")]
|
|
|
|
|
private static void RemoveComponentsFromSelected()
|
|
|
|
|
{
|
|
|
|
|
// 현재 선택된 오브젝트
|
|
|
|
|
GameObject selectedObject = Selection.activeGameObject;
|
|
|
|
|
|
|
|
|
|
if (selectedObject == null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogWarning("오브젝트를 선택하세요.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MeshCollider[] meshcoll = selectedObject.GetComponentsInChildren<MeshCollider>();
|
|
|
|
|
for (int i = 0; i < meshcoll.Length; i++)
|
|
|
|
|
Object.DestroyImmediate(meshcoll[i]);
|
|
|
|
|
|
|
|
|
|
CapsuleCollider[] capsuleCollider = selectedObject.GetComponentsInChildren<CapsuleCollider>();
|
|
|
|
|
for (int i = 0; i < capsuleCollider.Length; i++)
|
|
|
|
|
Object.DestroyImmediate(capsuleCollider[i]);
|
|
|
|
|
|
|
|
|
|
LODGroup[] lodGroup = selectedObject.GetComponentsInChildren<LODGroup>();
|
|
|
|
|
for (int i = 0; i < lodGroup.Length; i++)
|
|
|
|
|
Object.DestroyImmediate(lodGroup[i]);
|
|
|
|
|
}
|
2025-01-07 21:00:07 +00:00
|
|
|
[MenuItem("Tools/Child 0 name is parent name")]
|
|
|
|
|
private static void tttttttttttttttttttttttttttt()
|
|
|
|
|
{
|
|
|
|
|
var selectedObjects = Selection.gameObjects;
|
|
|
|
|
|
|
|
|
|
foreach (var go in selectedObjects)
|
|
|
|
|
{
|
|
|
|
|
go.transform.GetChild(0).name = go.name;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-23 04:56:38 +00:00
|
|
|
}
|