Missing Component 체크하기
작업을 하다보면 예기지 못하게 속성이 Missing으로 링크가 정상적이지 않는 경우가 생긴다.
Missing으로 표시가되는건 .meta 가 변경이되어서 읽을수 없는 경우
혹은 GUI가 변경이 되는 경우
이전에 사용된 Asset이 삭제,혹은 이동이 되어서 연결이 끊어진 경우 다양하다.
반응형
< Hierarchy 에서 경고 표시 >
'console.warnicon' 아이콘으로 노출
< Script Code >
var count = Utill.FindMissingReferences(_gameObject);
if (count > 0)
{
Debug.LogWarning($"Missing in Component :: {_gameObject.name} : {count}");
}
public static int FindMissingReferences(GameObject go)
{
var count = 0;
var components = go.GetComponents<Component>();
for (var j = 0; j < components.Length; j++)
{
var c = components[j];
if (!c)
{
Utill.ShowLogError($"Missing Component in GameObject: {go.name} go");
count++;
continue;
}
var so = new SerializedObject(c);
var sp = so.GetIterator();
while (sp.NextVisible(true))
{
if (sp.propertyType == SerializedPropertyType.ObjectReference)
{
if (sp.objectReferenceValue == null
&& sp.objectReferenceInstanceIDValue != 0)
{
count++;
}
}
}
}
return count;
}
unity-missing-references-finder : [링크]
unity-missing-references-finder/Editor/MissingReferencesFinder.cs at master · edcasillas/unity-missing-references-finder
A tool to find missing references in Unity. Contribute to edcasillas/unity-missing-references-finder development by creating an account on GitHub.
github.com
★★★★☆
반응형
'개발 > Unity' 카테고리의 다른 글
Unity) 스테인드 글라스 효과(Stained Glass) (1) | 2025.01.02 |
---|---|
Unity) 순차적인 Task 처리하기 위한 유틸 코드 (0) | 2024.12.18 |
Unity)UI Toolkit Debugger (0) | 2024.11.11 |
Unity) 홀로그램 효과 쉐이더 (0) | 2024.11.08 |
문제해결) 패키지 Error when executing git command. git: 'credential-winstore' is not a git command. See 'git --help'. fatal: could not read Username for 'https://gitlab.com': terminal prompts disabled (0) | 2024.11.06 |
댓글