private static bool AutoOpenCanvas(int rInstanceID, int rLine) { if (Selection.activeObject != null && Selection.activeObject is Spell) { SpellEditorWindow.OpenSpellEditor(); if (Instance != null) { string lAssetPath = AssetDatabase.GetAssetPath(rInstanceID); Instance.AssetPath = lAssetPath; Instance.Editor.LoadRootAsset(lAssetPath); return(true); } } return(false); }
/// <summary> /// Automatically opens the window when the spell is selected. /// </summary> public static bool OpenSpellEditor(int rInstanceID) { if (rInstanceID != 0) { SpellEditorWindow.OpenSpellEditor(); if (Instance != null) { string lAssetPath = AssetDatabase.GetAssetPath(rInstanceID); Instance.AssetPath = lAssetPath; Instance.Editor.LoadRootAsset(lAssetPath); return(true); } } return(false); }
/// <summary> /// Allows us to draw each item in the list /// </summary> /// <param name="rRect"></param> /// <param name="rIndex"></param> /// <param name="rIsActive"></param> /// <param name="rIsFocused"></param> private void DrawItemListItem(Rect rRect, int rIndex, bool rIsActive, bool rIsFocused) { if (rIndex < mTarget._Spells.Count) { SpellInventoryItem lItem = mTarget._Spells[rIndex]; rRect.y += 2; Rect lNameRect = new Rect(rRect.x, rRect.y, rRect.width - 60f, EditorGUIUtility.singleLineHeight); EditorGUI.LabelField(lNameRect, string.Format("[{0}] {1}", rIndex, lItem.Name)); Rect lButtonRect = new Rect(lNameRect.x + lNameRect.width + 10f, lNameRect.y, 50f, lNameRect.height); if (GUI.Button(lButtonRect, "open", EditorHelper.LinkLabel)) { int lInstance = lItem.SpellPrefab.GetInstanceID(); SpellEditorWindow.OpenSpellEditor(lInstance); } } }