private void SelectDatabase() { GUILayout.BeginHorizontal(); GUILayout.Label("Database", GUILayout.Width(70f)); if (GUILayout.Button(this.m_Database != null ? m_Database.name : "Null", EditorStyles.objectField)) { 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)) { this.m_Database = databases[i]; UtilityInstanceWindow.CloseWindow(); } } }); } GUILayout.EndHorizontal(); }
private void SelectDatabase(ItemDatabase current, UnityAction <ItemDatabase> result) { if (GUILayout.Button(current != null ? current.name : "Null", EditorStyles.objectField)) { 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)) { result.Invoke(databases[i]); UtilityInstanceWindow.CloseWindow(); Repaint(); } } }); } }
protected virtual void DoSelection(Rect position, SerializedProperty property, GUIContent label, T current) { if ((attribute as PickerAttribute).utility) { if (!string.IsNullOrEmpty(label.text)) { EditorGUI.LabelField(position, label); position.x += EditorGUIUtility.labelWidth; position.width = Screen.width - position.x - EditorStyles.inspectorDefaultMargins.padding.right; //- 18 * 2); } if (GUI.Button(position, current != null ? current.Name : "Null", EditorStyles.objectField)) { string searchString = "Search..."; UtilityInstanceWindow.ShowWindow(typeof(T).Name + " Picker (" + this.Database.name + ")", delegate() { searchString = EditorTools.SearchField(searchString); for (int i = 0; i < Items.Count; i++) { if (!string.IsNullOrEmpty(searchString) && !searchString.Equals("Search...") && !Items [i].Name.ToLower().Contains(searchString.ToLower())) { continue; } Color color = GUI.backgroundColor; GUI.backgroundColor = current != null && current.Name == Items [i].Name ? Color.green : color; if (GUILayout.Button(Items [i].Name)) { property.SetValue(Items[i]); // SetValue (Items [i], property); UtilityInstanceWindow.CloseWindow(); } GUI.backgroundColor = color; } }); } } else { int selectedIndex = Items.IndexOf(current); selectedIndex = Mathf.Clamp(selectedIndex, 0, Items.Count); // selectedIndex = EditorGUI.Popup(position, selectedIndex, Names); int index = EditorGUI.Popup(position, System.Text.RegularExpressions.Regex.Replace(typeof(T).Name, "([a-z])_?([A-Z])", "$1 $2"), selectedIndex, Names); if (selectedIndex != index) { property.SetValue(Items[index]); } // SetValue (Items [selectedIndex], property); } }
private void ShowBoneMap() { UtilityInstanceWindow.ShowWindow("Bones", delegate() { SelectDatabaseButton(); GUILayout.Space(3f); ItemDatabase database = this.m_Database.objectReferenceValue as ItemDatabase; if (database == null) { return; } List <EquipmentHandler.EquipmentBone> bones = (target as EquipmentHandler).Bones; var firstNotSecond = database.equipments.Except(bones.Select(x => x.region)).ToList(); var secondNotFirst = bones.Select(x => x.region).Except(database.equipments).ToList(); for (int i = 0; i < firstNotSecond.Count; i++) { InsertEquipmentBone(firstNotSecond[i]); } for (int i = 0; i < secondNotFirst.Count; i++) { bones.RemoveAll(x => x.region == secondNotFirst[i]); } SerializedProperty property = serializedObject.FindProperty("m_Bones"); serializedObject.Update(); EditorGUI.BeginChangeCheck(); for (int i = 0; i < property.arraySize; i++) { EditorGUILayout.BeginHorizontal(); SerializedProperty element = property.GetArrayElementAtIndex(i); EditorGUILayout.LabelField((element.FindPropertyRelative("region").objectReferenceValue as EquipmentRegion).Name, GUILayout.Width(120f)); EditorGUILayout.PropertyField(element.FindPropertyRelative("bone"), GUIContent.none); EditorGUILayout.EndHorizontal(); } if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(target); PrefabUtility.RecordPrefabInstancePropertyModifications(target); } }); }
protected override void DoSelection(Rect position, SerializedProperty property, GUIContent label, ItemGroup current) { if (!string.IsNullOrEmpty(label.text)) { EditorGUI.LabelField(position, label); position.x += EditorGUIUtility.labelWidth; position.width = Screen.width - EditorGUIUtility.labelWidth - 18 * 2; } if (GUI.Button(position, current != null ? current.Name : "Database", EditorStyles.objectField)) { string searchString = "Search..."; UtilityInstanceWindow.ShowWindow("Item Group Picker", delegate() { searchString = EditorTools.SearchField(searchString); Color color = GUI.backgroundColor; GUI.backgroundColor = current == null ? Color.green : color; if (GUILayout.Button("Database")) { property.SetValue(null); // SetValue(null, property); UtilityInstanceWindow.CloseWindow(); } GUI.backgroundColor = color; for (int i = 0; i < Items.Count; i++) { if (!string.IsNullOrEmpty(searchString) && !searchString.Equals("Search...") && !Items[i].Name.ToLower().Contains(searchString.ToLower())) { continue; } color = GUI.backgroundColor; GUI.backgroundColor = current != null && current.Name == Items[i].Name ? Color.green : color; if (GUILayout.Button(Items[i].Name)) { property.SetValue(Items[i]); //SetValue(Items[i], property); UtilityInstanceWindow.CloseWindow(); } GUI.backgroundColor = color; } }); } }
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..."; LoginConfigurations[] databases = UnityEditorUtility.FindAssets <LoginConfigurations>(); UtilityInstanceWindow.ShowWindow("Select Configuration", delegate() { searchString = UnityEditorUtility.SearchField(searchString); for (int i = 0; i < databases.Length; i++) { if (!string.IsNullOrEmpty(searchString) && !searchString.Equals("Search...") && !databases[i].name.Contains(searchString)) { continue; } databases[i].settings = databases[i].settings.OrderBy(x => x.Order).ToList(); 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")) { LoginConfigurations db = AssetCreator.CreateAsset <LoginConfigurations>(true); if (db != null) { ArrayUtility.Add <LoginConfigurations>(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; }); }