protected override void Draw()
        {
            if (serializedObject == null)
            {
                return;
            }
            var counterIndexProperty         = serializedObject.FindProperty("m_counterIndex");
            var counterValueModeProperty     = serializedObject.FindProperty("m_counterValueMode");
            var requiredCounterValueProperty = serializedObject.FindProperty("m_requiredCounterValue");

            UnityEngine.Assertions.Assert.IsNotNull(counterIndexProperty, "Quest Machine: Internal error - m_counterIndex is null.");
            UnityEngine.Assertions.Assert.IsNotNull(counterValueModeProperty, "Quest Machine: Internal error - m_counterValueMode is null.");
            UnityEngine.Assertions.Assert.IsNotNull(requiredCounterValueProperty, "Quest Machine: Internal error - m_requiredCounterValue is null.");
            if (counterIndexProperty == null || counterValueModeProperty == null || requiredCounterValueProperty == null)
            {
                Debug.LogError("Quest Machine: Internal error in CounterQuestConditionEditor. Please contact the developer.");
                return;
            }
            EditorGUILayout.HelpBox("This condition requires that the value of a counter defined in your quest meets a criteria such as being at least a specific amount.", MessageType.None);
            QuestEditorUtility.EditorGUILayoutCounterNamePopup(counterIndexProperty, m_nameList);
            EditorGUILayout.PropertyField(counterValueModeProperty);
            EditorGUILayout.PropertyField(requiredCounterValueProperty, true);
            if (GUILayout.Button("Refresh Counter Names"))
            {
                m_nameList = QuestEditorUtility.GetCounterNames();
            }
        }
 protected override void OnEnable()
 {
     base.OnEnable();
     if (target == null || serializedObject == null)
     {
         return;
     }
     m_nameList = QuestEditorUtility.GetCounterNames();
 }
        public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(rect, label, property);
            rect = EditorGUI.PrefixLabel(rect, GUIUtility.GetControlID(FocusType.Passive), label);
            try
            {
                var valueTypeProperty = property.FindPropertyRelative("m_valueType");
                UnityEngine.Assertions.Assert.IsNotNull(valueTypeProperty, "Quest Machine: Internal error - m_valueType is null.");
                if (valueTypeProperty == null)
                {
                    return;
                }
                EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight),
                                        valueTypeProperty, GUIContent.none);
                var valueType = (QuestNumber.ValueType)valueTypeProperty.enumValueIndex;
                var valueRect = new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight, rect.width, EditorGUIUtility.singleLineHeight);
                switch (valueType)
                {
                case QuestNumber.ValueType.Literal:
                    var literalValueProperty = property.FindPropertyRelative("m_literalValue");
                    UnityEngine.Assertions.Assert.IsNotNull(literalValueProperty, "Quest Machine: Internal error - m_literalValue is null.");
                    if (literalValueProperty == null)
                    {
                        return;
                    }
                    EditorGUI.PropertyField(valueRect, literalValueProperty, GUIContent.none);
                    break;

                case QuestNumber.ValueType.CounterValue:
                case QuestNumber.ValueType.CounterMinValue:
                case QuestNumber.ValueType.CounterMaxValue:
                    var counterIndexProperty = property.FindPropertyRelative("m_counterIndex");
                    if (m_counterNameList == null)
                    {
                        m_counterNameList = QuestEditorUtility.GetCounterNames();
                    }
                    if (counterIndexProperty != null)
                    {
                        QuestEditorUtility.EditorGUICounterNamePopup(valueRect, counterIndexProperty, m_counterNameList);
                    }
                    break;
                }
            }
            finally
            {
                EditorGUI.EndProperty();
            }
        }
示例#4
0
        protected override void Draw()
        {
            if (serializedObject == null)
            {
                return;
            }
            if (m_nameList == null)
            {
                m_nameList = QuestEditorUtility.GetCounterNames();
            }
            serializedObject.Update();
            var counterIndexProperty   = serializedObject.FindProperty("m_counterIndex");
            var operationProperty      = serializedObject.FindProperty("m_operation");
            var operationValueProperty = serializedObject.FindProperty("m_operationValue");
            var maxValueProperty       = serializedObject.FindProperty("m_maxValue");

            UnityEngine.Assertions.Assert.IsNotNull(counterIndexProperty, "Quest Machine: Internal error - m_counterIndex is null.");
            UnityEngine.Assertions.Assert.IsNotNull(operationProperty, "Quest Machine: Internal error - m_operation is null.");
            UnityEngine.Assertions.Assert.IsNotNull(operationValueProperty, "Quest Machine: Internal error - m_operationValue is null.");
            UnityEngine.Assertions.Assert.IsNotNull(maxValueProperty, "Quest Machine: Internal error - m_maxValue is null.");
            if (counterIndexProperty == null || operationProperty == null || operationValueProperty == null || maxValueProperty == null)
            {
                return;
            }
            QuestEditorUtility.EditorGUILayoutCounterNamePopup(counterIndexProperty, m_nameList);
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(operationProperty);
            if (EditorGUI.EndChangeCheck())
            {
                m_operationValueTooltip = null;
            }
            var operation = (SetCounterValueQuestAction.Operation)operationProperty.enumValueIndex;

            if (m_operationValueTooltip == null)
            {
                m_operationValueTooltip = GetOperationValueTooltip(operation);
            }
            EditorGUILayout.PropertyField(operationValueProperty, m_operationValueTooltip);
            if (operation == SetCounterValueQuestAction.Operation.Randomize)
            {
                EditorGUILayout.PropertyField(maxValueProperty);
            }
            serializedObject.ApplyModifiedProperties();
        }
        protected override void Draw()
        {
            if (serializedObject == null)
            {
                return;
            }
            EditorGUILayout.HelpBox("When this node becomes active, this condition starts a countdown using the counter defined in your quest. Make sure the counter value is set to your desired time before using this action. Every second, the counter value will decrease by one. If it reaches zero, the condition will be true.", MessageType.None);
            var counterIndexProperty = serializedObject.FindProperty("m_counterIndex");

            UnityEngine.Assertions.Assert.IsNotNull(counterIndexProperty, "Quest Machine: Internal error - m_counterIndex is null.");
            if (counterIndexProperty == null)
            {
                return;
            }
            QuestEditorUtility.EditorGUILayoutCounterNamePopup(counterIndexProperty, m_nameList);
            if (GUILayout.Button("Refresh Counter Names"))
            {
                m_nameList = QuestEditorUtility.GetCounterNames();
            }
        }