유니티 스크립트 Missing 한번에 지우기 (SelectGameObjectsWithMissingScripts)
Unity3D 2022. 5. 10. 12:04using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using UnityEngine.SceneManagement; //3
public class SelectGameObjectsWithMissingScripts : Editor
{
[MenuItem("smilejsu/Remove All Missing Script Components")]
private static void RemoveAllMissingScriptComponents() {
Object[] deepSelectedObjects = EditorUtility.CollectDeepHierarchy(Selection.gameObjects);
Debug.Log(deepSelectedObjects.Length);
int componentCount = 0;
int gameObjectCount = 0;
foreach (Object obj in deepSelectedObjects)
{
if (obj is GameObject go)
{
int count = GameObjectUtility.GetMonoBehavioursWithMissingScriptCount(go);
//Debug.LogFormat("<color=cyan>{0}</color>", count);
if (count > 0) {
Undo.RegisterCompleteObjectUndo(go, "Remove Missing Scripts");
GameObjectUtility.RemoveMonoBehavioursWithMissingScript(go);
componentCount += count;
gameObjectCount++;
}
}
}
}
}
게임 오브젝트를 선택하고 메뉴에서 Remove를 눌러주면
자식 오브젝트들을 모두 검색해 Missiing 난 스크립트 컴포넌트를 제거 합니다
'Unity3D' 카테고리의 다른 글
종스크롤 2D 슈팅게임 배경 스크롤링 (0) | 2023.02.05 |
---|---|
온디맨드 렌더링을 이용한 모바일 성능 개선 (0) | 2022.11.28 |
Load font from mobile device and assign as fallback TMP_FontAsset (0) | 2022.05.03 |
SphereCast & LayerMask (0) | 2022.03.31 |
HudText (damage text), world to screen position (0) | 2022.02.17 |