public static bool HandleOpenAsset(int instanceID, int line) { UnityEngine.Object obj = EditorUtility.InstanceIDToObject(instanceID); if (obj == null) { return(false); } Type type = obj.GetType(); if (type.IsSubclassOf(typeof(ScriptableObject))) { ScriptableObjectInspectorWindow.Init(( ScriptableObject )obj); return(true); } return(false); // No custom option was hit, leaving opening file to next handler }
public static void Init(ScriptableObject scriptableObject) { for (int i = 0; i < openWindows.Count; i++) { var currentWindow = openWindows[i]; // Check for the name to offer solution when the editor was closed if (currentWindow.titleContent.text == scriptableObject.name) { if (currentWindow.scriptableObject == null) { currentWindow.SetScriptableObject(scriptableObject); } currentWindow.Focus(); currentWindow.Show(); return; } } ScriptableObjectInspectorWindow window = (ScriptableObjectInspectorWindow)EditorWindow.CreateInstance(typeof(ScriptableObjectInspectorWindow)); window.titleContent = new GUIContent(scriptableObject.name); window.SetScriptableObject(scriptableObject); openWindows.Add(window); window.Show(); }