Created
June 17, 2020 16:52
-
-
Save korchoon/863f5cea1088ba4a659a0423586e0916 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEngine; | |
static class MissingScriptFix { | |
[MenuItem("Assets/- Fix MissingScripts Recursively on Selection")] | |
[MenuItem("GameObject/- Fix MissingScripts Recursively on Selection", false, -1)] | |
static void Fix() { | |
foreach (GameObject g in Selection.gameObjects) { | |
foreach (var t in g.GetComponentsInChildren<Transform>(true)) { | |
var i = GameObjectUtility.RemoveMonoBehavioursWithMissingScript(t.gameObject); | |
if (i <= 0) continue; | |
Debug.Log($"Removed {i} on {AnimationUtility.CalculateTransformPath(t, null)}"); | |
EditorUtility.SetDirty(t); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment