Ejemplo n.º 1
0
        private void DrawStateInfo(SerializedObject serializedObject)
        {
            UnityEngine.Assertions.Assert.IsNotNull(serializedObject, "Quest Machine: Internal error - serializedObject is null.");
            var foldout    = QuestEditorPrefs.GetStateInfoFoldout(0);
            var newFoldout = QuestEditorUtility.EditorGUILayoutFoldout("States", "Content specific to each state that the quest can be in.", foldout);

            if (newFoldout != foldout)
            {
                QuestEditorPrefs.ToggleStateInfoFoldout(0);
            }
            if (!newFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                EditorGUILayout.HelpBox("This section contains information specific to each state that the quest can be in.", MessageType.None);
                var stateInfoListProperty = serializedObject.FindProperty("m_stateInfoList");
                UnityEngine.Assertions.Assert.IsNotNull(stateInfoListProperty, "Quest Machine: Internal error - m_stateInfoList is null.");
                if (stateInfoListProperty == null)
                {
                    return;
                }
                if (stateInfoListProperty.arraySize == 0)
                {
                    stateInfoListProperty.arraySize = System.Enum.GetNames(typeof(QuestState)).Length;
                }
                if (m_inactiveStateInfoInspectorGUI == null)
                {
                    m_inactiveStateInfoInspectorGUI = new QuestStateInfoInspectorGUI();
                }
                if (m_activeStateInfoInspectorGUI == null)
                {
                    m_activeStateInfoInspectorGUI = new QuestStateInfoInspectorGUI();
                }
                if (m_successfulStateInfoInspectorGUI == null)
                {
                    m_successfulStateInfoInspectorGUI = new QuestStateInfoInspectorGUI();
                }
                if (m_failedStateInfoInspectorGUI == null)
                {
                    m_failedStateInfoInspectorGUI = new QuestStateInfoInspectorGUI();
                }
                if (m_abandonedStateInfoInspectorGUI == null)
                {
                    m_abandonedStateInfoInspectorGUI = new QuestStateInfoInspectorGUI();
                }
                m_inactiveStateInfoInspectorGUI.Draw(serializedObject, stateInfoListProperty.GetArrayElementAtIndex((int)QuestState.WaitingToStart), 0, QuestState.WaitingToStart);
                m_activeStateInfoInspectorGUI.Draw(serializedObject, stateInfoListProperty.GetArrayElementAtIndex((int)QuestState.Active), 0, QuestState.Active);
                m_successfulStateInfoInspectorGUI.Draw(serializedObject, stateInfoListProperty.GetArrayElementAtIndex((int)QuestState.Successful), 0, QuestState.Successful);
                m_failedStateInfoInspectorGUI.Draw(serializedObject, stateInfoListProperty.GetArrayElementAtIndex((int)QuestState.Failed), 0, QuestState.Failed);
                m_abandonedStateInfoInspectorGUI.Draw(serializedObject, stateInfoListProperty.GetArrayElementAtIndex((int)QuestState.Abandoned), 0, QuestState.Abandoned);
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
        private void HandlePlayModeStateChanged()
        {
#if DEBUG_QUEST_EDITOR
            Debug.Log("<color=magenta>QuestEditorWindow.OnPlaymodeStateChanged. Application.isPlaying=" + Application.isPlaying + "</color>");
#endif
            SelectQuestBasedOnCurrentSelection();
            QuestEditorStyles.ResetImages(); // Unity loses dynamically-created textures when switching playmode.
            QuestEditorPrefs.SavePrefs();
            Repaint();
        }
Ejemplo n.º 3
0
        private void DrawStateInfo(SerializedObject serializedObject, SerializedProperty nodeProperty, int nodeIndex)
        {
            UnityEngine.Assertions.Assert.IsNotNull(serializedObject, "Quest Machine: Internal error - serializedObject is null.");
            UnityEngine.Assertions.Assert.IsNotNull(nodeProperty, "Quest Machine: Internal error - nodeProperty is null.");

            //if (GUILayout.Button(new GUIContent("States", "Settings specific to each state that the quest node can be in."), GUI.skin.GetStyle(QuestEditorStyles.CollapsibleHeaderButtonStyleName)))
            //{
            //    QuestEditorPrefs.ToggleStateInfoFoldout(nodeIndex);
            //}
            //if (!QuestEditorPrefs.GetStateInfoFoldout(nodeIndex)) return;

            var foldout    = QuestEditorPrefs.GetStateInfoFoldout(nodeIndex);
            var newFoldout = QuestEditorUtility.EditorGUILayoutFoldout("States", "Settings specific to each state that the quest node can be in.", foldout);

            if (newFoldout != foldout)
            {
                QuestEditorPrefs.ToggleStateInfoFoldout(nodeIndex);
            }
            if (!newFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                EditorGUILayout.HelpBox("This section contains information specific to each state that the node can be in.", MessageType.None);

                var stateInfoListProperty = nodeProperty.FindPropertyRelative("m_stateInfoList");
                if (stateInfoListProperty.arraySize == 0)
                {
                    stateInfoListProperty.arraySize = System.Enum.GetNames(typeof(QuestNodeState)).Length;
                }

                if (inactiveStateInfoInspectorGUI == null)
                {
                    inactiveStateInfoInspectorGUI = new QuestNodeStateInfoInspectorGUI();
                }
                if (activeStateInfoInspectorGUI == null)
                {
                    activeStateInfoInspectorGUI = new QuestNodeStateInfoInspectorGUI();
                }
                if (trueStateInfoInspectorGUI == null)
                {
                    trueStateInfoInspectorGUI = new QuestNodeStateInfoInspectorGUI();
                }
                inactiveStateInfoInspectorGUI.Draw(serializedObject, stateInfoListProperty.GetArrayElementAtIndex((int)QuestNodeState.Inactive), nodeIndex, QuestNodeState.Inactive);
                activeStateInfoInspectorGUI.Draw(serializedObject, stateInfoListProperty.GetArrayElementAtIndex((int)QuestNodeState.Active), nodeIndex, QuestNodeState.Active);
                trueStateInfoInspectorGUI.Draw(serializedObject, stateInfoListProperty.GetArrayElementAtIndex((int)QuestNodeState.True), nodeIndex, QuestNodeState.True);
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }
        private void OnDisable()
        {
#if DEBUG_QUEST_EDITOR
            Debug.Log("<color=red>QuestEditorWindow.OnDisable</color>");
#endif
            m_instance = null;
            QuestEditorPrefs.SavePrefs();
            Undo.undoRedoPerformed -= Repaint;
#if UNITY_5 || UNITY_2017_1
            EditorApplication.playmodeStateChanged -= OnPlaymodeStateChanged;
#else
            EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
#endif
        }
        public void Draw(SerializedObject serializedObject, SerializedProperty stateInfoProperty, int nodeIndex, QuestState questState)
        {
            if (serializedObject == null || stateInfoProperty == null)
            {
                return;
            }

            var foldout    = QuestEditorPrefs.GetQuestStateFoldout(questState, nodeIndex);
            var newFoldout = QuestEditorUtility.EditorGUILayoutFoldout(questState.ToString(), string.Empty, foldout, false);

            if (newFoldout != foldout)
            {
                QuestEditorPrefs.ToggleQuestStateFoldout(questState, nodeIndex);
            }
            if (!newFoldout)
            {
                return;
            }

            if (m_categorizedContentDrawer == null)
            {
                m_categorizedContentDrawer = new CategorizedQuestContentInspectorGUI();
            }
            if (m_questActionListDrawer == null)
            {
                m_questActionListDrawer = new QuestActionListInspectorGUI(new GUIContent("Actions", "Actions that run when the quest enters this state."));
            }
            QuestEditorUtility.EditorGUILayoutBeginIndent();

            var categorizedContentListProperty = stateInfoProperty.FindPropertyRelative("m_categorizedContentList");

            m_categorizedContentDrawer.Draw(serializedObject, categorizedContentListProperty);

            var actionListProperty = stateInfoProperty.FindPropertyRelative("m_actionList");

            m_questActionListDrawer.Draw(actionListProperty);

            QuestEditorUtility.EditorGUILayoutEndIndent();
            EditorGUILayout.Space();
        }