private static void RemoveMissingComponents() { var i18n = VRCQuestToolsSettings.I18nResource; var obj = Selection.activeGameObject; var count = VRCSDKUtility.CountMissingComponentsInChildren(obj, true); Debug.Log($"[{VRCQuestTools.Name}] {obj.name} has {count} missing scripts in children"); if (count == 0) { EditorUtility.DisplayDialog(VRCQuestTools.Name, i18n.NoMissingComponentsMessage(obj.name), "OK"); return; } var needsToUnpackPrefab = PrefabUtility.IsPartOfPrefabInstance(obj); var message = i18n.MissingRemoverConfirmationMessage(obj.name); if (needsToUnpackPrefab) { message += $" ({i18n.UnpackPrefabMessage})"; } if (!EditorUtility.DisplayDialog(VRCQuestTools.Name, message, "OK", i18n.CancelLabel)) { return; } if (needsToUnpackPrefab) { Undo.SetCurrentGroupName("Remove Missing Components"); // Somehow unpacking is needed to apply changes to the scene file. PrefabUtility.UnpackPrefabInstance(obj, PrefabUnpackMode.OutermostRoot, InteractionMode.UserAction); Debug.Log($"[{VRCQuestTools.Name}] {obj.name} has been unpacked"); } VRCSDKUtility.RemoveMissingComponentsInChildren(obj, true); }
/// <inheritdoc/> public NotificationItem Validate(VRChatAvatar avatar) { if (!avatar.GameObject.activeInHierarchy) { return(null); } var hasDynamicBone = AssetUtility.IsDynamicBoneImported(); if (VRCSDKUtility.CountMissingComponentsInChildren(avatar.GameObject, true) > 0) { return(new NotificationItem(() => { if (avatar.AvatarDescriptor == null) { return true; } var i18n = VRCQuestToolsSettings.I18nResource; if (hasDynamicBone) { GUILayout.Label(i18n.MissingScripts, EditorStyles.wordWrappedLabel); } else { GUILayout.Label(i18n.MissingDynamicBone, EditorStyles.wordWrappedLabel); } GUILayout.Label($"- {avatar.GameObject.name}", EditorStyles.wordWrappedLabel); if (GUILayout.Button(i18n.RemoveMissing)) { Selection.activeGameObject = avatar.GameObject; EditorApplication.ExecuteMenuItem(VRCQuestToolsMenus.MenuPaths.RemoveMissingComponents); return false; } return false; })); } return(null); }