private void SelectDatabaseButton() { GUIStyle buttonStyle = EditorStyles.objectField; GUIContent buttonContent = new GUIContent(this.m_Database != null ? this.m_Database.name : "Null"); Rect buttonRect = GUILayoutUtility.GetRect(180f, 18f); buttonRect.y += 1f; if (GUI.Button(buttonRect, buttonContent, buttonStyle)) { ObjectPickerWindow.ShowWindow(buttonRect, typeof(ItemDatabase), (UnityEngine.Object obj) => { this.m_Database = obj as ItemDatabase; ResetChildEditors(); }, () => { ItemDatabase db = EditorTools.CreateAsset <ItemDatabase>(true); if (db != null) { CreateDefaultCategory(db); this.m_Database = db; ResetChildEditors(); } }); } }
public virtual void Draw() { if (GUILayout.Button(buttonName)) { if (!AssetDatabase.IsValidFolder(FullFolderPath)) { AssetDatabase.CreateFolder("Assets/", folderPath); } EditorTools.CreateAsset(typeof(TScriptableObject), FullFolderPath + '/' + FullFileName); } }
public static void CreateDamageNature() { DamageNature damage = GetDamageNature(); if (GetDamageNature() == null) { EditorTools.CreateAsset <DamageNature>("DamageNature"); } else { Selection.activeObject = damage; } }
protected virtual void DoSelection(Rect buttonRect, SerializedProperty property, GUIContent label, Quest current) { GUIStyle buttonStyle = EditorStyles.objectField; GUIContent buttonContent = new GUIContent(current != null ? current.Name : "Null"); if (GUI.Button(buttonRect, buttonContent, buttonStyle)) { ObjectPickerWindow.ShowWindow(buttonRect, typeof(QuestDatabase), BuildSelectableObjects(), (UnityEngine.Object obj) => { property.serializedObject.Update(); property.objectReferenceValue = obj; property.serializedObject.ApplyModifiedProperties(); }, () => { QuestDatabase db = EditorTools.CreateAsset <QuestDatabase>(true); }); } }
public static void SelectDatabase(UnityAction onSelect) { string searchString = "Search..."; ItemDatabase[] databases = EditorTools.FindAssets <ItemDatabase>(); UtilityInstanceWindow.ShowWindow("Select Database", delegate() { searchString = EditorTools.SearchField(searchString); for (int i = 0; i < databases.Length; i++) { if (!string.IsNullOrEmpty(searchString) && !searchString.Equals("Search...") && !databases[i].name.Contains(searchString)) { continue; } GUIStyle style = new GUIStyle("button"); style.wordWrap = true; if (GUILayout.Button(AssetDatabase.GetAssetPath(databases[i]), style)) { Database = databases[i]; if (Database.categories.Count == 0) { CreateDefaultCategory(Database); } onSelect?.Invoke(); } } GUILayout.FlexibleSpace(); Color color = GUI.backgroundColor; GUI.backgroundColor = Color.green; if (GUILayout.Button("Create")) { ItemDatabase db = EditorTools.CreateAsset <ItemDatabase>(true); if (db != null) { CreateDefaultCategory(db); ArrayUtility.Add <ItemDatabase>(ref databases, db); } } GUI.backgroundColor = color; }); }
private void SelectDatabase() { string searchString = "Search..."; QuestDatabase[] databases = EditorTools.FindAssets <QuestDatabase>(); UtilityInstanceWindow.ShowWindow("Select Database", delegate() { searchString = EditorTools.SearchField(searchString); for (int i = 0; i < databases.Length; i++) { if (!string.IsNullOrEmpty(searchString) && !searchString.Equals("Search...") && !databases[i].name.Contains(searchString)) { continue; } GUIStyle style = new GUIStyle("button"); style.wordWrap = true; if (GUILayout.Button(AssetDatabase.GetAssetPath(databases[i]), style)) { database = databases[i]; ResetChildEditors(); Show(); UtilityInstanceWindow.CloseWindow(); } } GUILayout.FlexibleSpace(); Color color = GUI.backgroundColor; GUI.backgroundColor = Color.green; if (GUILayout.Button("Create")) { QuestDatabase db = EditorTools.CreateAsset <QuestDatabase>(true); if (db != null) { ArrayUtility.Add <QuestDatabase>(ref databases, db); } } GUI.backgroundColor = color; }); }
public static void CreateFaction() { EditorTools.CreateAsset <Faction>("new faction"); }