Ejemplo n.º 1
0
        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();
                        }
                    }
                });
            }
        }
Ejemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.PropertyField(this.m_Script);
            EditorGUI.EndDisabledGroup();
            serializedObject.Update();
            EditorGUILayout.PropertyField(this.m_WindowName);
            serializedObject.ApplyModifiedProperties();

            if (EditorTools.RightArrowButton(new GUIContent("Bones"), GUILayout.Height(24f)))
            {
                if (InventorySystemEditor.Database == null)
                {
                    InventorySystemEditor.SelectDatabase(delegate { UtilityInstanceWindow.CloseWindow(); ShowBoneMap(); });
                }
                else
                {
                    ShowBoneMap();
                }
            }

            if (EditorTools.RightArrowButton(new GUIContent("Items"), GUILayout.Height(24f)))
            {
                VisibleItemsEditor.ShowWindow("Items", serializedObject.FindProperty("m_VisibleItems"));
            }

            if (EditorWindow.mouseOverWindow != null)
            {
                EditorWindow.mouseOverWindow.Repaint();
            }
        }
        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();
        }
Ejemplo n.º 4
0
 private void SelectDatabase()
 {
     SelectDatabase(delegate {
         ResetChildEditors();
         Show();
         UtilityInstanceWindow.CloseWindow();
     });
 }
Ejemplo n.º 5
0
 private void OnGUI()
 {
     if (childEditors != null)
     {
         EditorGUILayout.Space();
         GUILayout.BeginHorizontal();
         GUILayout.FlexibleSpace();
         SelectDatabase(Database, delegate { ResetChildEditors(); UtilityInstanceWindow.CloseWindow(); });
         toolbarIndex = GUILayout.Toolbar(toolbarIndex, toolbarNames, GUILayout.MinWidth(200));
         GUILayout.FlexibleSpace();
         GUILayout.EndHorizontal();
         childEditors [toolbarIndex].OnGUI(new Rect(0f, 30f, position.width, position.height - 30f));
     }
 }
Ejemplo n.º 6
0
        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);
            }
        }
        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;
                    }
                });
            }
        }
Ejemplo n.º 8
0
        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;
            });
        }
Ejemplo n.º 9
0
        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;
            });
        }