From 39da3b6742cbe861e021dd03e1af0647204e18f8 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 22 Aug 2023 18:50:08 +0900 Subject: [PATCH] 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_ --- .../Editor/AvatarProcessor.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Packages/nadena.dev.modular-avatar/Editor/AvatarProcessor.cs b/Packages/nadena.dev.modular-avatar/Editor/AvatarProcessor.cs index bb23905c..b19805cb 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/AvatarProcessor.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/AvatarProcessor.cs @@ -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(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 } } } -} \ No newline at end of file +}