Created
December 8, 2013 11:09
-
-
Save baba-s/7855986 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 System.Linq; | |
using UnityEditor; | |
using UnityEngine; | |
/// <summary> | |
/// Missing Scriptsを抽出するスクリプト | |
/// </summary> | |
[InitializeOnLoad] | |
internal class MissingScriptChecker : Editor | |
{ | |
/// <summary> | |
/// エディタ起動時にMissing Scriptsを抽出する | |
/// </summary> | |
static MissingScriptChecker() | |
{ | |
if (EditorApplication.isPlaying || Application.isPlaying) | |
{ | |
return; | |
} | |
Check(); | |
} | |
/// <summary> | |
/// メニューからMissing Scriptsを抽出する | |
/// </summary> | |
[MenuItem("Tools/Check/Missing Script")] | |
private static void CheckMissingScript() | |
{ | |
Check(); | |
} | |
/// <summary> | |
/// Missing Scriptsを抽出する | |
/// </summary> | |
private static void Check() | |
{ | |
Debug.Log("Start Missing Script Checker"); | |
// 1. 全てのゲームオブジェクトを見つけます | |
// 2. 各々のオブジェクトをチェックします | |
// 3. 全てのコンポーネントを取得します | |
// 4. null を戻すものがあるか確認します | |
var brokenList = | |
Resources.FindObjectsOfTypeAll(typeof(GameObject)).Cast<GameObject>().Where( | |
c => c.GetComponents<MonoBehaviour>().Any(o => o == null)).ToList(); | |
foreach (var broken in brokenList) | |
{ | |
Debug.LogError(broken.name, broken); | |
} | |
Debug.Log("Complete Missing Script Checker"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment