Example #1
0
        private void OnAddElement(ReorderableList list)
        {
            ReorderableList.defaultBehaviours.DoAddButton(list);
            var newCounterProperty = list.serializedProperty.GetArrayElementAtIndex(list.index);

            if (newCounterProperty != null)
            {
                var counterNameProperty = newCounterProperty.FindPropertyRelative("m_name");
                if (counterNameProperty != null)
                {
                    StringFieldDrawer.SetStringFieldValue(counterNameProperty, string.Empty);
                }
                var maxValueProperty = newCounterProperty.FindPropertyRelative("m_maxValue");
                if (maxValueProperty != null)
                {
                    maxValueProperty.intValue = InitialMaxCounterValue;
                }
                var messageEventListProperty = newCounterProperty.FindPropertyRelative("m_messageEventList");
                if (messageEventListProperty != null)
                {
                    messageEventListProperty.ClearArray();
                }
            }
            OnSelectElement(list);
        }
Example #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var m_icon        = property.FindPropertyRelative("m_icon");
            var m_headingText = property.FindPropertyRelative("m_headingText");
            var m_bodyText    = property.FindPropertyRelative("m_bodyText");

            EditorGUI.BeginProperty(position, label, property);
            try
            {
                var rect   = position;
                var height = EditorGUIUtility.singleLineHeight;
                EditorGUI.LabelField(new Rect(rect.x, rect.y, rect.width, height), label, QuestEditorStyles.CollapsibleSubheaderButtonStyleName);
                rect.y += height;

                EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, height), m_icon);
                rect.y += height;

                height = StringFieldDrawer.GetHeight(m_headingText);
                EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, height), m_headingText);
                rect.y += height;

                height = StringFieldDrawer.GetHeight(m_bodyText);
                EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, height), m_bodyText);
            }
            finally
            {
                EditorGUI.EndProperty();
            }
        }
        private void OnDrawNodeElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            if (!(0 <= index && index < m_nodeList.serializedProperty.arraySize))
            {
                return;
            }
            var element              = m_nodeList.serializedProperty.GetArrayElementAtIndex(index);
            var idProperty           = element.FindPropertyRelative("m_id");
            var internalNameProperty = element.FindPropertyRelative("m_internalName");

            UnityEngine.Assertions.Assert.IsNotNull(idProperty, "Quest Machine: Internal error - m_id is null.");
            UnityEngine.Assertions.Assert.IsNotNull(internalNameProperty, "Quest Machine: Internal error - m_internalName is null.");
            if (idProperty == null || internalNameProperty == null)
            {
                return;
            }
            EditorGUI.BeginDisabledGroup(true);
            try
            {
                EditorGUI.TextField(new Rect(rect.x, rect.y, rect.width / 2, EditorGUIUtility.singleLineHeight),
                                    StringFieldDrawer.GetStringFieldValue(idProperty));
                EditorGUI.TextField(new Rect(rect.x + rect.width / 2, rect.y, rect.width / 2, EditorGUIUtility.singleLineHeight),
                                    StringFieldDrawer.GetStringFieldValue(internalNameProperty));
            }
            finally
            {
                EditorGUI.EndDisabledGroup();
            }
        }
        public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(rect, label, property);

            float height = 0;

            var dialogueTextProperty = property.FindPropertyRelative("m_dialogueText");
            var fieldHeight          = StringFieldDrawer.GetHeight(dialogueTextProperty);

            StringFieldDrawer.Draw(new Rect(rect.x, rect.y + height, rect.width, fieldHeight), dialogueTextProperty, new GUIContent("Dialogue Text"), false);
            height += fieldHeight;

            var journalTextProperty = property.FindPropertyRelative("m_journalText");

            fieldHeight = StringFieldDrawer.GetHeight(journalTextProperty);
            StringFieldDrawer.Draw(new Rect(rect.x, rect.y + height, rect.width, fieldHeight), journalTextProperty, new GUIContent("Journal Text"), false);
            height += fieldHeight;

            var hudTextProperty = property.FindPropertyRelative("m_hudText");

            fieldHeight = StringFieldDrawer.GetHeight(hudTextProperty);
            StringFieldDrawer.Draw(new Rect(rect.x, rect.y + height, rect.width, fieldHeight), hudTextProperty, new GUIContent("HUD Text"), false);
            height += fieldHeight;

            var alertTextProperty = property.FindPropertyRelative("m_alertText");

            fieldHeight = StringFieldDrawer.GetHeight(alertTextProperty);
            StringFieldDrawer.Draw(new Rect(rect.x, rect.y + height, rect.width, fieldHeight), alertTextProperty, new GUIContent("Alert Text"), false);
            height += fieldHeight;

            EditorGUI.EndProperty();
        }
        private string GetNodeText(SerializedProperty nodeProperty)
        {
            if (nodeProperty == null)
            {
                return(string.Empty);
            }
            var internalNameProperty = nodeProperty.FindPropertyRelative("m_internalName");

            UnityEngine.Assertions.Assert.IsNotNull(internalNameProperty, "Quest Machine: Internal error - m_internalName property is null.");
            if (internalNameProperty == null)
            {
                return(string.Empty);
            }
            var text = StringFieldDrawer.GetStringFieldValue(internalNameProperty);

            if (string.IsNullOrEmpty(text))
            {
                var idProperty = nodeProperty.FindPropertyRelative("m_id");
                UnityEngine.Assertions.Assert.IsNotNull(idProperty, "Quest Machine: Internal error - m_id property is null.");
                if (idProperty == null)
                {
                    return(string.Empty);
                }
                text = StringFieldDrawer.GetStringFieldValue(idProperty);
            }
            return(text);
        }
        private void DrawQuestTitle()
        {
            var titleProperty = m_questSerializedObject.FindProperty("m_title");

            UnityEngine.Assertions.Assert.IsNotNull(titleProperty, "Quest Machine: Internal error - m_title property is null.");
            if (titleProperty == null)
            {
                return;
            }
            var displayName = StringFieldDrawer.GetStringFieldValue(titleProperty);

            if (string.IsNullOrEmpty(displayName))
            {
                var idProperty = m_questSerializedObject.FindProperty("m_id");
                if (idProperty != null)
                {
                    displayName = StringFieldDrawer.GetStringFieldValue(idProperty);
                }
                if (string.IsNullOrEmpty(displayName))
                {
                    displayName = m_questSerializedObject.targetObject.name;
                }
            }
            if (m_quest.isInstance)
            {
                displayName += " (runtime: " + m_quest.GetState() + ")";
            }
            EditorGUILayout.LabelField(displayName, QuestEditorStyles.questNameGUIStyle);
        }
 public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
 {
     return
         (StringFieldDrawer.GetHeight(property.FindPropertyRelative("m_dialogueText")) +
          StringFieldDrawer.GetHeight(property.FindPropertyRelative("m_journalText")) +
          StringFieldDrawer.GetHeight(property.FindPropertyRelative("m_hudText")) +
          StringFieldDrawer.GetHeight(property.FindPropertyRelative("m_alertText")));
 }
Example #8
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            var m_headingText = property.FindPropertyRelative("m_headingText");
            var m_bodyText    = property.FindPropertyRelative("m_bodyText");

            return(2 * EditorGUIUtility.singleLineHeight +
                   StringFieldDrawer.GetHeight(m_headingText) +
                   StringFieldDrawer.GetHeight(m_bodyText));
        }
Example #9
0
        public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(rect, label, property);

            var textProperty = property.FindPropertyRelative("m_text");

            if (textProperty == null)
            {
                return;
            }
            StringFieldDrawer.Draw(rect, textProperty, label, true);

            var driveValuesProperty = property.FindPropertyRelative("m_driveValues");

            if (driveValuesProperty == null)
            {
                return;
            }
            var textHeight = (StringFieldDrawer.NumExpandedLines + 2) * EditorGUIUtility.singleLineHeight;

            EditorGUI.LabelField(new Rect(rect.x, rect.y + textHeight, rect.width / 2, EditorGUIUtility.singleLineHeight), "Drive");
            EditorGUI.LabelField(new Rect(rect.x + rect.width / 2, rect.y + textHeight, rect.width / 2, EditorGUIUtility.singleLineHeight), "Value");
            if (GUI.Button(new Rect(rect.x + rect.width - 30, rect.y + textHeight, 30, EditorGUIUtility.singleLineHeight), "+", EditorStyles.miniButton))
            {
                driveValuesProperty.arraySize++;
            }
            int indexToDelete = -1;

            for (int i = 0; i < driveValuesProperty.arraySize; i++)
            {
                var driveValueProperty = driveValuesProperty.GetArrayElementAtIndex(i);
                if (driveValuesProperty == null)
                {
                    continue;
                }
                var driveProperty = driveValueProperty.FindPropertyRelative("m_drive");
                var valueProperty = driveValueProperty.FindPropertyRelative("m_value");
                if (driveProperty == null || valueProperty == null)
                {
                    continue;
                }
                EditorGUI.PropertyField(new Rect(rect.x, rect.y + textHeight + (i + 1) * EditorGUIUtility.singleLineHeight, rect.width / 2, EditorGUIUtility.singleLineHeight), driveProperty, GUIContent.none);
                EditorGUI.PropertyField(new Rect(rect.x + rect.width / 2, rect.y + textHeight + (i + 1) * EditorGUIUtility.singleLineHeight, (rect.width / 2) - 30, EditorGUIUtility.singleLineHeight), valueProperty, GUIContent.none);
                if (GUI.Button(new Rect(rect.x + rect.width - 30, rect.y + textHeight + (i + 1) * EditorGUIUtility.singleLineHeight, 30, EditorGUIUtility.singleLineHeight), "-", EditorStyles.miniButtonRight))
                {
                    indexToDelete = i;
                }
            }
            if (indexToDelete != -1)
            {
                driveValuesProperty.DeleteArrayElementAtIndex(indexToDelete);
            }

            EditorGUI.EndProperty();
        }
Example #10
0
        private void OnDrawElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            if (!(0 <= index && index < m_list.serializedProperty.arraySize))
            {
                return;
            }
            var element = m_list.serializedProperty.GetArrayElementAtIndex(index);

            if (element == null)
            {
                return;
            }
            var currentValueProperty = element.FindPropertyRelative("m_currentValue");
            var currentValue         = (currentValueProperty != null) ? currentValueProperty.intValue : 0;

            EditorGUI.LabelField(rect, StringFieldDrawer.GetStringFieldValue(element.FindPropertyRelative("m_name")) + ": " + currentValue);
        }
        private void AddNode(QuestNodeType questNodeType, Vector2 mousePosition, int parentIndex)
        {
            var parentNodeProperty = (parentIndex >= 0) ? m_nodeListProperty.GetArrayElementAtIndex(parentIndex) : null;

            m_nodeListProperty.arraySize++;
            QuestEditorWindow.selectedNodeListIndex = m_nodeListProperty.arraySize - 1;
            var childIndex   = m_nodeListProperty.arraySize - 1;
            var nodeProperty = m_nodeListProperty.GetArrayElementAtIndex(childIndex);

            UnityEngine.Assertions.Assert.IsNotNull(nodeProperty, "Quest Machine: Internal error - node property is null in AddNode().");
            if (nodeProperty == null)
            {
                return;
            }
            var idProperty = nodeProperty.FindPropertyRelative("m_id");

            UnityEngine.Assertions.Assert.IsNotNull(idProperty, "Quest Machine: Internal error - m_id property is null in AddNode().");
            if (idProperty == null)
            {
                return;
            }
            var internalNameProperty = nodeProperty.FindPropertyRelative("m_internalName");

            UnityEngine.Assertions.Assert.IsNotNull(internalNameProperty, "Quest Machine: Internal error - m_internalName property is null in AddNode().");
            if (internalNameProperty == null)
            {
                return;
            }
            var stateProperty = nodeProperty.FindPropertyRelative("m_state");

            UnityEngine.Assertions.Assert.IsNotNull(stateProperty, "Quest Machine: Internal error - m_state property is null in AddNode().");
            if (stateProperty == null)
            {
                return;
            }
            var nodeTypeProperty = nodeProperty.FindPropertyRelative("m_nodeType");

            UnityEngine.Assertions.Assert.IsNotNull(nodeTypeProperty, "Quest Machine: Internal error - m_nodeType property is null in AddNode().");
            if (nodeTypeProperty == null)
            {
                return;
            }
            var isOptionalProperty = nodeProperty.FindPropertyRelative("m_isOptional");

            UnityEngine.Assertions.Assert.IsNotNull(isOptionalProperty, "Quest Machine: Internal error - m_isOptional property is null in AddNode().");
            if (isOptionalProperty == null)
            {
                return;
            }
            var stateInfoListProperty = nodeProperty.FindPropertyRelative("m_stateInfoList");

            UnityEngine.Assertions.Assert.IsNotNull(stateInfoListProperty, "Quest Machine: Internal error - m_stateInfoList property is null in AddNode().");
            if (stateInfoListProperty == null)
            {
                return;
            }
            var conditionSetProperty = nodeProperty.FindPropertyRelative("m_conditionSet");

            UnityEngine.Assertions.Assert.IsNotNull(conditionSetProperty, "Quest Machine: Internal error - m_conditionSet property is null in AddNode().");
            if (conditionSetProperty == null)
            {
                return;
            }
            var conditionListProperty = conditionSetProperty.FindPropertyRelative("m_conditionList");

            UnityEngine.Assertions.Assert.IsNotNull(conditionListProperty, "Quest Machine: Internal error - m_conditionList property is null in AddNode().");
            if (conditionListProperty == null)
            {
                return;
            }
            var conditionCountModeProperty = conditionSetProperty.FindPropertyRelative("m_conditionCountMode");

            UnityEngine.Assertions.Assert.IsNotNull(conditionCountModeProperty, "Quest Machine: Internal error - m_conditionCountMode property is null in AddNode().");
            if (conditionCountModeProperty == null)
            {
                return;
            }
            var canvasRectProperty = nodeProperty.FindPropertyRelative("m_canvasRect");

            UnityEngine.Assertions.Assert.IsNotNull(canvasRectProperty, "Quest Machine: Internal error - m_canvasRect property is null in AddNode().");
            if (canvasRectProperty == null)
            {
                return;
            }
            var initialName = (questNodeType == QuestNodeType.Success) ? "Success"
                : ((questNodeType == QuestNodeType.Failure) ? "Failure"
                   : questNodeType.ToString() + " " + (m_nodeListProperty.arraySize - 1));

            StringFieldDrawer.SetStringFieldValue(idProperty, initialName);
            StringFieldDrawer.SetStringFieldValue(internalNameProperty, string.Empty);
            stateProperty.enumValueIndex    = (int)QuestState.WaitingToStart;
            nodeTypeProperty.enumValueIndex = (int)questNodeType;
            isOptionalProperty.boolValue    = false;
            stateInfoListProperty.ClearArray();
            conditionListProperty.ClearArray();
            conditionCountModeProperty.enumValueIndex = (int)ConditionCountMode.All;
            ClearConnections(nodeProperty);
            var height = (questNodeType == QuestNodeType.Success || questNodeType == QuestNodeType.Failure) ? QuestEditorStyles.shortNodeHeight : QuestEditorStyles.nodeHeight;
            var rect   = (parentNodeProperty != null) ? GetRectForNewChild(parentNodeProperty, height)
                : new Rect(mousePosition.x, mousePosition.y, QuestEditorStyles.nodeWidth, height);

            canvasRectProperty.rectValue = rect;
            if (parentNodeProperty != null)
            {
                AddConnection(parentIndex, childIndex);
            }
        }
        public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(rect, label, property);
            try
            {
                var nameProperty = property.FindPropertyRelative("m_name");
                UnityEngine.Assertions.Assert.IsNotNull(nameProperty, "Quest Machine: Internal error - m_name is null.");
                if (nameProperty == null)
                {
                    return;
                }

                var y          = rect.y;
                var nameHeight = StringFieldDrawer.GetHeight(nameProperty);
                EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, nameHeight),
                                        nameProperty, new GUIContent("Name", "The counter's name."));
                y += nameHeight;

                var randomizeProperty = property.FindPropertyRelative("m_randomizeInitialValue");
                UnityEngine.Assertions.Assert.IsNotNull(randomizeProperty, "Quest Machine: Internal error - m_randomizeInitialValue is null.");
                if (randomizeProperty == null)
                {
                    return;
                }
                EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, EditorGUIUtility.singleLineHeight),
                                        randomizeProperty, new GUIContent("Randomize Initial Value", "Initialize to a random value between Min Value and Max Value."));
                y += EditorGUIUtility.singleLineHeight;

                if (randomizeProperty.boolValue)
                {
                    EditorGUI.BeginDisabledGroup(true);
                }
                var currentValueProperty = property.FindPropertyRelative("m_currentValue");
                UnityEngine.Assertions.Assert.IsNotNull(currentValueProperty, "Quest Machine: Internal error - m_currentValue is null.");
                if (currentValueProperty == null)
                {
                    return;
                }
                EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, EditorGUIUtility.singleLineHeight),
                                        currentValueProperty, new GUIContent("Current Value", "The counter's current value."));
                y += EditorGUIUtility.singleLineHeight;
                if (randomizeProperty.boolValue)
                {
                    EditorGUI.EndDisabledGroup();
                }

                var minValueProperty = property.FindPropertyRelative("m_minValue");
                UnityEngine.Assertions.Assert.IsNotNull(minValueProperty, "Quest Machine: Internal error - m_minValue is null.");
                var maxValueProperty = property.FindPropertyRelative("m_maxValue");
                UnityEngine.Assertions.Assert.IsNotNull(maxValueProperty, "Quest Machine: Internal error - m_maxValue is null.");
                if (minValueProperty == null)
                {
                    return;
                }
                if (maxValueProperty == null)
                {
                    return;
                }

                var isMinMaxInvalid = maxValueProperty.intValue <= minValueProperty.intValue;

                var originalColor = GUI.color;
                if (isMinMaxInvalid)
                {
                    GUI.color = Color.red;
                }

                EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, EditorGUIUtility.singleLineHeight),
                                        minValueProperty, new GUIContent("Min Value", "Minimum value counter can have."));
                y += EditorGUIUtility.singleLineHeight;

                EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, EditorGUIUtility.singleLineHeight),
                                        maxValueProperty, new GUIContent("Max Value", "Maximum value counter can have."));
                y += EditorGUIUtility.singleLineHeight;

                if (isMinMaxInvalid)
                {
                    GUI.color = originalColor;
                }

                var updateModeProperty = property.FindPropertyRelative("m_updateMode");
                UnityEngine.Assertions.Assert.IsNotNull(updateModeProperty, "Quest Machine: Internal error - m_updateMode is null.");
                if (updateModeProperty == null)
                {
                    return;
                }
                EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, EditorGUIUtility.singleLineHeight),
                                        updateModeProperty, new GUIContent("Value Mode", "If Data Sync, synchronizes value with a DataSynchronizer component using the exact name specified above. If Messages, adjusts value based on Message System messages defined below."));
                y += EditorGUIUtility.singleLineHeight;

                if (updateModeProperty.enumValueIndex == (int)QuestCounterUpdateMode.Messages)
                {
                    rect = new Rect(rect.x + 18, rect.y, rect.width - 18, rect.height);
                    int indexToDelete            = -1;
                    var messageEventListProperty = property.FindPropertyRelative("m_messageEventList");
                    UnityEngine.Assertions.Assert.IsNotNull(messageEventListProperty, "Quest Machine: Internal error - m_messageEventList is null.");
                    if (messageEventListProperty == null)
                    {
                        return;
                    }
                    for (int i = 0; i < messageEventListProperty.arraySize; i++)
                    {
                        var messageEventProperty    = messageEventListProperty.GetArrayElementAtIndex(i);
                        var senderSpecifierProperty = messageEventProperty.FindPropertyRelative("m_senderSpecifier");
                        var senderIDProperty        = messageEventProperty.FindPropertyRelative("m_senderID");
                        var targetSpecifierProperty = messageEventProperty.FindPropertyRelative("m_targetSpecifier");
                        var targetIDProperty        = messageEventProperty.FindPropertyRelative("m_targetID");
                        var messageProperty         = messageEventProperty.FindPropertyRelative("m_message");
                        var parameterProperty       = messageEventProperty.FindPropertyRelative("m_parameter");
                        var operationProperty       = messageEventProperty.FindPropertyRelative("m_operation");
                        var literalValueProperty    = messageEventProperty.FindPropertyRelative("m_literalValue");
                        if (senderSpecifierProperty == null || senderIDProperty == null || targetSpecifierProperty == null || targetIDProperty == null ||
                            messageProperty == null || parameterProperty == null || operationProperty == null || literalValueProperty == null)
                        {
                            continue;
                        }

                        var height = EditorGUIUtility.singleLineHeight;
                        EditorGUI.BeginChangeCheck();
                        EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, height), senderSpecifierProperty,
                                                new GUIContent("Sender", "Required message sender."), true);
                        if (EditorGUI.EndChangeCheck())
                        {
                            QuestEditorUtility.SetMessageParticipantID(senderSpecifierProperty, senderIDProperty);
                        }
                        y += height;

                        if (senderSpecifierProperty.enumValueIndex == (int)QuestMessageParticipant.Other)
                        {
                            height = StringFieldDrawer.GetHeight(senderIDProperty);
                            EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, height), senderIDProperty,
                                                    new GUIContent("Sender ID", "Required message sender ID, or any sender if blank. Can also be {QUESTERID} or {QUESTGIVERID}. Sender must have a Quest Giver or Entity component."), true);
                            y += height;
                        }

                        height = EditorGUIUtility.singleLineHeight;
                        EditorGUI.BeginChangeCheck();
                        EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, height), targetSpecifierProperty,
                                                new GUIContent("Target", "Required message target."), true);
                        if (EditorGUI.EndChangeCheck())
                        {
                            QuestEditorUtility.SetMessageParticipantID(targetSpecifierProperty, targetIDProperty);
                        }
                        y += height;

                        if (targetSpecifierProperty.enumValueIndex == (int)QuestMessageParticipant.Other)
                        {
                            height = StringFieldDrawer.GetHeight(targetIDProperty);
                            EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, height), targetIDProperty,
                                                    new GUIContent("Target ID", "Required message target ID, or any sender if blank. Can also be {QUESTERID} or {QUESTGIVERID}. Target must have a Quest Giver or Entity component."), true);
                            y += height;
                        }

                        height = StringFieldDrawer.GetHeight(messageProperty);
                        EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, height), messageProperty,
                                                new GUIContent("Message", "When this message and the parameter below are sent, update the counter according to the operation below."), true);
                        y     += height;
                        height = StringFieldDrawer.GetHeight(parameterProperty);
                        EditorGUI.PropertyField(new Rect(rect.x, y, rect.width, height), parameterProperty,
                                                new GUIContent("Parameter", "When the message above and this parameter are sent, update the counter according to the operation below."), true);
                        y += height;
                        var fieldWidth = (rect.width - 30f) / 2f;
                        var operation  = (QuestCounterMessageEvent.Operation)operationProperty.enumValueIndex;
                        if (operation == QuestCounterMessageEvent.Operation.ModifyByParameter || operation == QuestCounterMessageEvent.Operation.SetToParameter)
                        {
                            EditorGUI.PropertyField(new Rect(rect.x, y, rect.width - 30f, EditorGUIUtility.singleLineHeight), operationProperty, GUIContent.none);
                        }
                        else
                        {
                            EditorGUI.PropertyField(new Rect(rect.x, y, fieldWidth, EditorGUIUtility.singleLineHeight), operationProperty, GUIContent.none);
                            EditorGUI.PropertyField(new Rect(rect.x + fieldWidth, y, fieldWidth, EditorGUIUtility.singleLineHeight), literalValueProperty, GUIContent.none);
                        }
                        if (GUI.Button(new Rect(rect.x + rect.width - 30f, y, 30f, EditorGUIUtility.singleLineHeight), new GUIContent("-", "Delete this message event.")))
                        {
                            indexToDelete = i;
                        }
                        y += EditorGUIUtility.singleLineHeight;
                    }
                    if (indexToDelete != -1)
                    {
                        messageEventListProperty.DeleteArrayElementAtIndex(indexToDelete);
                    }
                    if (GUI.Button(new Rect(rect.x + rect.width - 80f, y, 80f, EditorGUIUtility.singleLineHeight),
                                   new GUIContent("Add Message", "Add a new message event for the counter."), EditorStyles.miniButton))
                    {
                        messageEventListProperty.arraySize++;
                        var messageEventProperty = messageEventListProperty.GetArrayElementAtIndex(messageEventListProperty.arraySize - 1);
                        messageEventProperty.FindPropertyRelative("m_senderSpecifier").enumValueIndex = (int)QuestMessageParticipant.Any;
                        messageEventProperty.FindPropertyRelative("m_targetSpecifier").enumValueIndex = (int)QuestMessageParticipant.Any;
                        messageEventProperty.FindPropertyRelative("m_message").FindPropertyRelative("m_text").stringValue   = string.Empty;
                        messageEventProperty.FindPropertyRelative("m_parameter").FindPropertyRelative("m_text").stringValue = string.Empty;
                        messageEventProperty.FindPropertyRelative("m_operation").enumValueIndex = (int)QuestCounterMessageEvent.Operation.ModifyByLiteralValue;
                        messageEventProperty.FindPropertyRelative("m_literalValue").intValue    = 1;
                    }
                }
            }
            finally
            {
                EditorGUI.EndProperty();
            }
        }
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            if (property == null)
            {
                return(base.GetPropertyHeight(property, label));
            }

            // Height of m_name:
            var nameProperty = property.FindPropertyRelative("m_name");

            UnityEngine.Assertions.Assert.IsNotNull(nameProperty, "Quest Machine: Internal error - m_name is null.");
            if (nameProperty == null)
            {
                return(base.GetPropertyHeight(property, label));
            }
            var height = StringFieldDrawer.GetHeight(nameProperty);

            // Height of current/min/max/random values:
            height += 4 * EditorGUIUtility.singleLineHeight;

            // Height of m_updateMode:
            var updateModeProperty = property.FindPropertyRelative("m_updateMode");

            UnityEngine.Assertions.Assert.IsNotNull(updateModeProperty, "Quest Machine: Internal error - m_updateMode is null.");
            if (updateModeProperty == null)
            {
                return(base.GetPropertyHeight(property, label));
            }
            height += EditorGUIUtility.singleLineHeight;

            // Optional height of m_messageEventList:
            if (updateModeProperty.enumValueIndex == (int)QuestCounterUpdateMode.Messages)
            {
                var messageEventListProperty = property.FindPropertyRelative("m_messageEventList");
                UnityEngine.Assertions.Assert.IsNotNull(messageEventListProperty, "Quest Machine: Internal error - m_messageEventList is null.");
                if (messageEventListProperty == null)
                {
                    return(base.GetPropertyHeight(property, label));
                }
                for (int i = 0; i < messageEventListProperty.arraySize; i++)
                {
                    var messageEventProperty    = messageEventListProperty.GetArrayElementAtIndex(i);
                    var senderSpecifierProperty = messageEventProperty.FindPropertyRelative("m_senderSpecifier");
                    var senderIDProperty        = messageEventProperty.FindPropertyRelative("m_senderID");
                    var targetSpecifierProperty = messageEventProperty.FindPropertyRelative("m_targetSpecifier");
                    var targetIDProperty        = messageEventProperty.FindPropertyRelative("m_targetID");
                    var messageProperty         = messageEventProperty.FindPropertyRelative("m_message");
                    var parameterProperty       = messageEventProperty.FindPropertyRelative("m_parameter");
                    if (senderSpecifierProperty != null && senderIDProperty != null && targetSpecifierProperty != null && targetIDProperty != null &&
                        messageProperty != null && parameterProperty != null)
                    {
                        height += EditorGUIUtility.singleLineHeight; // Sender specifier.
                        if (senderSpecifierProperty.enumValueIndex == (int)QuestMessageParticipant.Other)
                        {
                            height += StringFieldDrawer.GetHeight(senderIDProperty);
                        }
                        height += EditorGUIUtility.singleLineHeight; // Target specifier.
                        if (targetSpecifierProperty.enumValueIndex == (int)QuestMessageParticipant.Other)
                        {
                            height += StringFieldDrawer.GetHeight(targetIDProperty);
                        }
                        height += StringFieldDrawer.GetHeight(messageProperty);
                        height += StringFieldDrawer.GetHeight(parameterProperty);
                        height += EditorGUIUtility.singleLineHeight; // 'Operation' dropdown & 'Delete' button.
                    }
                }
                height += EditorGUIUtility.singleLineHeight; // 'Add' button.
            }
            return(height);
        }