示例#1
0
        // PUBLIC STATIC METHODS: -----------------------------------------------------------------

        public static GUIContent GetContent(ContentType type, ContentStyle style)
        {
            QuestToolbarUtils.RequireDataSetup();
            return(DATA[(int)type].Get(style));
        }
        private void PaintQuestToolbar()
        {
            bool hasSelection   = this.questsTree.HasSelection();
            int  selectionCount = (hasSelection ? this.questsTree.GetSelection().Count : 0);
            bool selectionRoot  = (
                selectionCount > 0 &&
                this.questsTree.GetSelection().Contains(QuestsTreeView.ROOT_ID)
                );

            System.Type selectionType = null;
            if (selectionCount == 1)
            {
                int    instanceID = this.questsTree.GetSelection()[0];
                IQuest instance   = this.InstanceIDToObject(instanceID);
                selectionType = (instance != null ? instance.GetType() : null);
            }

            QuestToolbarUtils.ContentStyle contentStyle = QuestToolbarUtils.ContentStyle.IconOnly;
            GUIContent gcQuest  = QuestToolbarUtils.GetContent(QuestToolbarUtils.ContentType.Quest, contentStyle);
            GUIContent gcTask   = QuestToolbarUtils.GetContent(QuestToolbarUtils.ContentType.Task, contentStyle);
            GUIContent gcDelete = QuestToolbarUtils.GetContent(QuestToolbarUtils.ContentType.Delete, contentStyle);

            EditorGUILayout.BeginHorizontal();
            GUILayoutOption height = GUILayout.Height(18f);

            EditorGUI.BeginDisabledGroup(!QuestEditor.CanAddElement(selectionCount, selectionType));
            if (GUILayout.Button(gcQuest, this.styleBtnLeft, height))
            {
                QuestEditor.AddElement(this);
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(!TaskEditor.CanAddElement(selectionCount, selectionType));
            if (GUILayout.Button(gcTask, this.styleBtnMid, height))
            {
                TaskEditor.AddElement(this);
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(!hasSelection || selectionRoot);
            if (GUILayout.Button(gcDelete, this.styleBtnRight, height) && this.questsTree.HasSelection())
            {
                List <int> items = new List <int>(this.questsTree.GetSelection());
                this.DeleteItems(items);
                AssetDatabase.ImportAsset(QuestUtilities.GetQuestsRootPath());
                this.questsTree.Reload();
            }
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.Space();
            this.questsTree.searchString = this.searchField.OnGUI(this.questsTree.searchString);
            EditorGUILayout.Space();

            if (GUILayout.Button(SETTINGS, this.styleBtn))
            {
                QuestsSettingsWindow settings = new QuestsSettingsWindow(this.spSettings);
                PopupWindow.Show(this.settingsRect, settings);
            }

            if (UnityEngine.Event.current.type == EventType.Repaint)
            {
                this.settingsRect = GUILayoutUtility.GetLastRect();
            }

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
        }