Skip to content

Instantly share code, notes, and snippets.

@BeautyfullCastle
Last active September 3, 2018 15:41
Show Gist options
  • Save BeautyfullCastle/a6d0e4aab21aa3492e2358eaf1d61fa0 to your computer and use it in GitHub Desktop.
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.
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