示例#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();
            }
        }
示例#2
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();
            }
        }