Last active
September 3, 2018 15:41
-
-
Save BeautyfullCastle/a6d0e4aab21aa3492e2358eaf1d61fa0 to your computer and use it in GitHub Desktop.
Unity editor window to find referenced game objects of selected script in currently opened scene.
This file contains 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.Collections.Generic; | |
using UnityEditor; | |
using UnityEngine; | |
public class ScriptReferencesFinder : EditorWindow | |
{ | |
private Vector2 scrollPosition; | |
private List<MonoBehaviour> references = new List<MonoBehaviour>(); | |
private static MonoScript field = null; | |
private static ScriptReferencesFinder assetReferenceFinder = null; | |
[MenuItem("Script References Finder/Find References", false, 0)] | |
private static void FindReferences() | |
{ | |
assetReferenceFinder = GetWindow<ScriptReferencesFinder>(); | |
} | |
private static void Find() | |
{ | |
if (field == null) | |
{ | |
return; | |
} | |
var components = UnityEngine.Resources.FindObjectsOfTypeAll<MonoBehaviour>(); | |
if (components == null || components.Length <= 0) | |
{ | |
return; | |
} | |
var matchedComponents = ArrayUtility.FindAll(components, (reference) => | |
{ | |
var mObj = reference as Object; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment