예제 #1
0
 private void DrawSelectedContent()
 {
     if (m_selectedQuestContent == null)
     {
         return;
     }
     if (m_contentEditor == null)
     {
         m_contentEditor = Editor.CreateEditor(m_selectedQuestContent);
     }
     QuestEditorUtility.EditorGUILayoutBeginIndent();
     m_contentEditor.OnInspectorGUI();
     QuestEditorUtility.EditorGUILayoutEndIndent();
 }
 private void DrawSelectedAction()
 {
     if (m_selectedAction == null)
     {
         return;
     }
     if (m_actionEditor == null)
     {
         m_actionEditor = Editor.CreateEditor(m_selectedAction);
     }
     QuestEditorUtility.EditorGUILayoutBeginIndent();
     m_actionEditor.OnInspectorGUI();
     QuestEditorUtility.EditorGUILayoutEndIndent();
 }
        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();
        }
예제 #4
0
        private void DrawMainInfo(SerializedObject serializedObject)
        {
            UnityEngine.Assertions.Assert.IsNotNull(serializedObject, "Quest Machine: Internal error - serializedObject is null.");
            QuestEditorPrefs.mainInfoFoldout = QuestEditorUtility.EditorGUILayoutFoldout("Quest Info", "Main quest info.", QuestEditorPrefs.mainInfoFoldout);
            if (!QuestEditorPrefs.mainInfoFoldout)
            {
                return;
            }

            try
            {
                QuestEditorUtility.EditorGUILayoutBeginGroup();
                var idProperty                   = serializedObject.FindProperty("m_id");
                var titleProperty                = serializedObject.FindProperty("m_title");
                var iconProperty                 = serializedObject.FindProperty("m_icon");
                var groupProperty                = serializedObject.FindProperty("m_group");
                var labelsProperty               = serializedObject.FindProperty("m_labels");
                var questGiverIDProperty         = serializedObject.FindProperty("m_questGiverID");
                var isTrackableProperty          = serializedObject.FindProperty("m_isTrackable");
                var showInTrackHUDProperty       = serializedObject.FindProperty("m_showInTrackHUD");
                var isAbandonableProperty        = serializedObject.FindProperty("m_isAbandonable");
                var rememberIfAbandonedProperty  = serializedObject.FindProperty("m_rememberIfAbandoned");
                var maxTimesProperty             = serializedObject.FindProperty("m_maxTimes");
                var timesAcceptedProperty        = serializedObject.FindProperty("m_timesAccepted");
                var cooldownSecondsProperty      = serializedObject.FindProperty("m_cooldownSeconds");
                var noRepeatIfSuccessfulProperty = serializedObject.FindProperty("m_noRepeatIfSuccessful");
                var stateProperty                = serializedObject.FindProperty("m_state");
                UnityEngine.Assertions.Assert.IsNotNull(idProperty, "Quest Machine: Internal error - m_id is null.");
                UnityEngine.Assertions.Assert.IsNotNull(titleProperty, "Quest Machine: Internal error - m_title is null.");
                UnityEngine.Assertions.Assert.IsNotNull(iconProperty, "Quest Machine: Internal error - m_icon is null.");
                UnityEngine.Assertions.Assert.IsNotNull(groupProperty, "Quest Machine: Internal error - m_group is null.");
                UnityEngine.Assertions.Assert.IsNotNull(labelsProperty, "Quest Machine: Internal error - m_labels is null.");
                UnityEngine.Assertions.Assert.IsNotNull(questGiverIDProperty, "Quest Machine: Internal error - m_questGiverID is null.");
                UnityEngine.Assertions.Assert.IsNotNull(isTrackableProperty, "Quest Machine: Internal error - m_isTrackable is null.");
                UnityEngine.Assertions.Assert.IsNotNull(showInTrackHUDProperty, "Quest Machine: Internal error - m_showInTrackHUD is null.");
                UnityEngine.Assertions.Assert.IsNotNull(isAbandonableProperty, "Quest Machine: Internal error - m_isAbandonable is null.");
                UnityEngine.Assertions.Assert.IsNotNull(rememberIfAbandonedProperty, "Quest Machine: Internal error - m_rememberIfAbandoned is null.");
                UnityEngine.Assertions.Assert.IsNotNull(maxTimesProperty, "Quest Machine: Internal error - m_maxTimes is null.");
                UnityEngine.Assertions.Assert.IsNotNull(timesAcceptedProperty, "Quest Machine: Internal error - m_timesAccepted is null.");
                UnityEngine.Assertions.Assert.IsNotNull(cooldownSecondsProperty, "Quest Machine: Internal error - m_cooldownSeconds is null.");
                UnityEngine.Assertions.Assert.IsNotNull(noRepeatIfSuccessfulProperty, "Quest Machine: Internal error - m_noRepeatIfSuccessful is null.");
                UnityEngine.Assertions.Assert.IsNotNull(stateProperty, "Quest Machine: Internal error - m_state is null.");
                if (idProperty == null || titleProperty == null || groupProperty == null || labelsProperty == null ||
                    iconProperty == null || questGiverIDProperty == null || isTrackableProperty == null || showInTrackHUDProperty == null ||
                    isAbandonableProperty == null || rememberIfAbandonedProperty == null || maxTimesProperty == null ||
                    timesAcceptedProperty == null || cooldownSecondsProperty == null || noRepeatIfSuccessfulProperty == null ||
                    stateProperty == null)
                {
                    return;
                }

                EditorGUILayout.PropertyField(idProperty, true);
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(titleProperty, true);
                EditorGUILayout.PropertyField(groupProperty, true);
                QuestEditorUtility.EditorGUILayoutBeginIndent();
                EditorGUILayout.PropertyField(labelsProperty, true);
                QuestEditorUtility.EditorGUILayoutEndIndent();
                EditorGUILayout.PropertyField(iconProperty);
                EditorGUILayout.PropertyField(questGiverIDProperty, true);
                EditorGUILayout.PropertyField(isTrackableProperty);
                if (isTrackableProperty.boolValue)
                {
                    EditorGUILayout.PropertyField(showInTrackHUDProperty);
                }
                EditorGUILayout.PropertyField(isAbandonableProperty);
                if (isAbandonableProperty.boolValue)
                {
                    EditorGUILayout.PropertyField(rememberIfAbandonedProperty);
                }
                EditorGUILayout.PropertyField(maxTimesProperty);
                if (maxTimesProperty.intValue > 1)
                {
                    EditorGUILayout.PropertyField(cooldownSecondsProperty);
                    EditorGUILayout.PropertyField(noRepeatIfSuccessfulProperty);
                }
                var prevState = stateProperty.enumValueIndex;
                EditorGUILayout.PropertyField(stateProperty, new GUIContent("Current State", "Current quest state."));
                var newState = stateProperty.enumValueIndex;
                if (Application.isPlaying && newState != prevState)
                {
                    // State changed in editor at runtime. Perform runtime state change with all the associated processing:
                    stateProperty.enumValueIndex = prevState;
                    serializedObject.ApplyModifiedProperties();
                    QuestEditorWindow.selectedQuest.SetState((QuestState)newState);
                    serializedObject.Update();
                }
            }
            finally
            {
                QuestEditorUtility.EditorGUILayoutEndGroup();
            }
        }