Пример #1
0
 protected virtual List <Quest> GetItems(QuestDatabase database)
 {
     System.Type type = fieldInfo.FieldType;
     if (typeof(IList).IsAssignableFrom(fieldInfo.FieldType))
     {
         type = Utility.GetElementType(fieldInfo.FieldType);
     }
     return(database.items.Where(x => type.IsAssignableFrom(x.GetType())).ToList());
 }
Пример #2
0
 public void OnEnable()
 {
     this.m_Database = AssetDatabase.LoadAssetAtPath <QuestDatabase>(EditorPrefs.GetString("QuestDatabasePath"));
     if (this.m_Database == null)
     {
         string[] guids = AssetDatabase.FindAssets("t:QuestDatabase");
         if (guids.Length > 0)
         {
             string path = AssetDatabase.GUIDToAssetPath(guids[0]);
             this.m_Database = AssetDatabase.LoadAssetAtPath <QuestDatabase>(path);
         }
     }
     ResetChildEditors();
 }
Пример #3
0
        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);
                });
            }
        }
Пример #4
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;
            });
        }
Пример #5
0
        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);

            if (GUI.Button(buttonRect, buttonContent, buttonStyle))
            {
                ObjectPickerWindow.ShowWindow(buttonRect, typeof(QuestDatabase),
                                              (UnityEngine.Object obj) => {
                    this.m_Database = obj as QuestDatabase;
                    ResetChildEditors();
                },
                                              () => {
                    QuestDatabase db = EditorTools.CreateAsset <QuestDatabase>(true);
                    if (db != null)
                    {
                        this.m_Database = db;
                        ResetChildEditors();
                    }
                });
            }
        }