Skip to content

Instantly share code, notes, and snippets.

@stella3d
Created September 28, 2018 20:25
Show Gist options
  • Save stella3d/8f514e495adb4b18dd765ae96af7fc00 to your computer and use it in GitHub Desktop.
Save stella3d/8f514e495adb4b18dd765ae96af7fc00 to your computer and use it in GitHub Desktop.
check if a window resource exists without creating it
using UnityEditor;
using UnityEngine;
public static class FindWindow
{
[MenuItem("Debug/FindWindow")]
public static bool DoesWindowExist()
{
var windowType = typeof(SceneView); // substitute with your own type
var allInstances = Resources.FindObjectsOfTypeAll(windowType);
if (allInstances.Length > 0)
{
Debug.Log("found window of type: " + windowType);
return true;
}
Debug.Log("did not find window of type: " + windowType);
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment