chore: remove all components with missing script (#404)

* chore: remove all components with missing script
* Traverse disabled gameobjects when purging missing scripts

Co-authored-by: bd_ <bd_@nadena.dev>
This commit is contained in:
anatawa12 2023-08-22 18:50:08 +09:00 committed by GitHub
parent 6591f35a78
commit 39da3b6742
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -171,6 +171,8 @@ namespace nadena.dev.modular_avatar.core.editor
AssetDatabase.StartAssetEditing();
nowProcessing = true;
RemoveMissingScriptComponents(avatarGameObject);
ClearEditorOnlyTagComponents(avatarGameObject.transform);
BoneDatabase.ResetBones();
@ -296,6 +298,12 @@ namespace nadena.dev.modular_avatar.core.editor
Debug.Log($"Processed avatar " + avatarGameObject.name + " in " + sw.ElapsedMilliseconds + "ms");
}
private static void RemoveMissingScriptComponents(GameObject avatarGameObject)
{
foreach (var child in avatarGameObject.GetComponentsInChildren<Transform>(true))
GameObjectUtility.RemoveMonoBehavioursWithMissingScript(child.gameObject);
}
private static void ClearEditorOnlyTagComponents(Transform obj)
{
// EditorOnly objects can be used for multiple purposes - users might want a camera rig to be available in
@ -381,4 +389,4 @@ namespace nadena.dev.modular_avatar.core.editor
}
}
}
}
}