Exemple #1
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            SerializedProperty animatorProperty  = serializedObject.FindProperty("_Animator");
            SerializedProperty layerNameProperty = serializedObject.FindProperty("_LayerName");
            SerializedProperty stateNameProperty = serializedObject.FindProperty("_StateName");

            EditorGUILayout.PropertyField(animatorProperty);

            if (animatorProperty.FindPropertyRelative("_Type").enumValueIndex == EnumUtility.GetIndexFromValue(FlexibleType.Constant))
            {
                Animator animator = animatorProperty.FindPropertyRelative("_Value").objectReferenceValue as Animator;

                EditorGUITools.AnimatorStateField(animator, layerNameProperty, stateNameProperty);
            }
            else
            {
                EditorGUILayout.PropertyField(layerNameProperty);
                EditorGUILayout.PropertyField(stateNameProperty);
            }

            EditorGUILayout.PropertyField(serializedObject.FindProperty("_TransitionDuration"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_NormalizedTime"));

            serializedObject.ApplyModifiedProperties();
        }
Exemple #2
0
 void OnGUI()
 {
     if (showPanBorder)
     {
         Color color = new Color(1f, 0, 0, 0.5f);
         EditorGUITools.DrawRect(_panBorders, color);
     }
 }
        private void OnAddDropdown(Rect buttonRect, ReorderableList list)
        {
            GenericMenu genericMenu = new GenericMenu();

            foreach (object userData in System.Enum.GetValues(typeof(CalculatorCondition.Type)))
            {
                genericMenu.AddItem(EditorGUITools.GetTextContent(userData.ToString()), false, AddConditionMenu, userData);
            }

            genericMenu.DropDown(buttonRect);
        }
        void DrawElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            SerializedProperty blendShapeProperty = _BlendShapeList.serializedProperty.GetArrayElementAtIndex(index);

            GUIContent label = EditorGUI.BeginProperty(rect, EditorGUITools.GetTextContent(blendShapeProperty.displayName), blendShapeProperty);

            rect.height = _BlendShapeList.elementHeight;
            EditorGUI.PrefixLabel(rect, label);
            rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;

            SerializedProperty targetProperty = blendShapeProperty.FindPropertyRelative("_Target");

            rect.height = EditorGUI.GetPropertyHeight(targetProperty);
            EditorGUI.PropertyField(rect, targetProperty);
            rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;

            SerializedProperty nameProperty = blendShapeProperty.FindPropertyRelative("_Name");

            rect.height = EditorGUI.GetPropertyHeight(nameProperty);
            EditorGUI.PropertyField(rect, nameProperty);
            rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;

            SerializedProperty tweenMoveTypeProperty = blendShapeProperty.FindPropertyRelative("_TweenMoveType");

            rect.height = EditorGUI.GetPropertyHeight(tweenMoveTypeProperty);
            EditorGUI.PropertyField(rect, tweenMoveTypeProperty);
            rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;

            SerializedProperty fromProperty  = blendShapeProperty.FindPropertyRelative("_From");
            TweenMoveType      tweenMoveType = EnumUtility.GetValueFromIndex <TweenMoveType>(tweenMoveTypeProperty.enumValueIndex);

            switch (tweenMoveType)
            {
            case TweenMoveType.Absolute:
            case TweenMoveType.Relative:
            {
                rect.height = EditorGUI.GetPropertyHeight(fromProperty);
                EditorGUI.PropertyField(rect, fromProperty);
                rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;
            }
            break;

            case TweenMoveType.ToAbsolute:
                break;
            }

            SerializedProperty toProperty = blendShapeProperty.FindPropertyRelative("_To");

            rect.height = EditorGUI.GetPropertyHeight(toProperty);
            EditorGUI.PropertyField(rect, toProperty);
            rect.y += rect.height;

            EditorGUI.EndProperty();
        }
 public override void OnGUI(Rect rect)
 {
     EditorGUILayout.BeginVertical("box");
     GUILayout.Label("Choose a name:", EditorStyles.boldLabel);
     m_TextData = EditorGUILayout.TextField(m_TextData);
     if (EditorGUITools.Button(m_ButtonText, true))
     {
         m_Callback(m_TextData);
         editorWindow.Close();
     }
     EditorGUILayout.EndVertical();
 }
        /*************
        * Right Menu *
        *************/
        private void DrawRightMenu()
        {
            EditorGUILayout.BeginVertical("box");
            m_MainWindowScrollView = EditorGUILayout.BeginScrollView(m_MainWindowScrollView, false, false);
            {
                if (_CurrentUTADirector == null)
                {
                    EditorGUILayout.HelpBox("Select an animation or a create a new one using the left menu", MessageType.Info);
                }
                else
                {
                    GUIStyle centeredLabel = new GUIStyle(EditorStyles.boldLabel)
                    {
                        alignment = TextAnchor.UpperCenter
                    };
                    EditorGUILayout.LabelField(_CurrentUTADirector.name, centeredLabel);

                    EditorGUILayout.Space();

                    //if (EditorGUITools.Button("Rename", c_ColorSave, GUILayout.Width(150)))
                    //{
                    //    AskTextPopup.Show("Rename", RenameCurrentObject);
                    //}

                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (EditorGUITools.Button("Duplicate", c_ColorDuplicate, GUILayout.Width(150)))
                    {
                        AskTextPopup.Show("Duplicate", DuplicateCurrentObject);
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (EditorGUITools.Button("Delete", c_ColorDelete, GUILayout.Width(150)))
                    {
                        if (EditorUtility.DisplayDialog("Delete animation?", "Are you sure you want to delete this animation ?", "Do it!", "Hell no!"))
                        {
                            DeleteCurrentObject();
                        }
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
        }
 /*****************
 * Startup Helper *
 *****************/
 private void DrawStartupHelper()
 {
     EditorGUILayout.BeginVertical("box");
     {
         EditorGUILayout.HelpBox("It seems like you're starting up the UTA lib for the first time on this scene. Would you like to start the setup ?", MessageType.Warning);
         GUILayout.BeginHorizontal();
         GUILayout.FlexibleSpace();
         if (EditorGUITools.Button("Do it!", c_ColorNew, true, GUILayout.Width(100)))
         {
             CreateUTAController();
         }
         GUILayout.FlexibleSpace();
         GUILayout.EndHorizontal();
     }
     EditorGUILayout.EndVertical();
 }
Exemple #8
0
    void OnGUI()
    {
        if (GUILayout.Button("Load"))
        {
            container = ItemDatabase.Load();
        }

        if (GUILayout.Button("Save"))
        {
            container.Save();
        }

        if (container != null)
        {
            for (int i = 0, n = container.items.Count; i < n; i++)
            {
                if (EditorGUITools.DrawHeader(container.items[i].name, container.items[i].name))
                {
                    EditorGUILayout.BeginHorizontal();
                    container.items[i].name = EditorGUILayout.TextField(container.items[i].name);
                    EditorGUILayout.BeginVertical();
                    for (int j = 0, n2 = container.items[i].effects.Count; j < n2; j++)
                    {
                        container.items[i].effects[j].senseEffected = (SenseType)EditorGUILayout.EnumPopup(container.items[i].effects[j].senseEffected);
//						container.items[i].effects[j].want = EditorGUILayout.Popup(0, WantsList.Load<WantsList>());
                        container.items[i].effects[j].value = EditorGUILayout.FloatField(container.items[i].effects[j].value);
                    }
                    EditorGUILayout.EndVertical();
                    if (GUILayout.Button("Add Effect", GUILayout.ExpandWidth(false)))
                    {
                        container.items[i].AddEffect();
                    }
                    //				container.items[i].name = EditorGUILayout.TextField("Name", container.items[i].name, GUILayout.ExpandWidth(false));
                    //				container.items[i].need = EditorGUILayout.TextField("Need", container.items[i].need);
                    //				container.items[i].effect = EditorGUILayout.FloatField("Effect", container.items[i].effect);
                    EditorGUILayout.EndHorizontal();
                }
            }

            GUILayout.Space(10);

            if (GUILayout.Button("New Item", GUILayout.ExpandWidth(false)))
            {
                container.NewItem();
            }
        }
    }
        void DeleteParameter(SerializedProperty elementProperty, CalculatorCondition.Type type, bool deleteParameter)
        {
            SerializedProperty parametersProperty = GetParametersProperty(type);

            if (parametersProperty == null)
            {
                return;
            }

            SerializedProperty parameterIndexProperty = elementProperty.FindPropertyRelative(kParameterIndexPath);
            int parameterIndex = parameterIndexProperty.intValue;
            SerializedProperty parameterProperty = parametersProperty.GetArrayElementAtIndex(parameterIndex);

            if (parameterProperty == null)
            {
                return;
            }

            foreach (object valueObj in EditorGUITools.GetPropertyObjects(parameterProperty))
            {
                EachField <DataSlot> .Find(valueObj, valueObj.GetType(), (s) =>
                {
                    s.Disconnect();
                });
            }

            if (deleteParameter)
            {
                parametersProperty.DeleteArrayElementAtIndex(parameterIndex);

                for (int i = 0, count = _ConditionsList.serializedProperty.arraySize; i < count; i++)
                {
                    SerializedProperty       p = _ConditionsList.serializedProperty.GetArrayElementAtIndex(i);
                    CalculatorCondition.Type t = GetType(p);
                    if (t != type)
                    {
                        continue;
                    }
                    SerializedProperty indexProperty = p.FindPropertyRelative(kParameterIndexPath);
                    if (indexProperty.intValue > parameterIndex)
                    {
                        indexProperty.intValue--;
                    }
                }
            }
        }
            private float ElementHeight(int index)
            {
                SerializedProperty valueProperty  = _ValuesProperty.GetArrayElementAtIndex(index);
                SerializedProperty weightProperty = _WeightsProperty.GetArrayElementAtIndex(index);

                float height = list.elementHeight + EditorGUIUtility.standardVerticalSpacing;

                if (onPreValueFieldCallback != null)
                {
                    onPreValueFieldCallback(valueProperty);
                }
                height += EditorGUI.GetPropertyHeight(valueProperty, EditorGUITools.GetTextContent("Value"), true) + EditorGUIUtility.standardVerticalSpacing;
                height += EditorGUI.GetPropertyHeight(weightProperty, EditorGUITools.GetTextContent("Weight"), true) + EditorGUIUtility.standardVerticalSpacing;
                height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

                return(height);
            }
Exemple #11
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(serializedObject.FindProperty("_IsCheckTag"));

            SerializedProperty tagProperty = serializedObject.FindProperty("_Tag");

            EditorGUI.BeginChangeCheck();
            string tag = EditorGUILayout.TagField(EditorGUITools.NicifyVariableName(tagProperty.name), tagProperty.stringValue);

            if (EditorGUI.EndChangeCheck())
            {
                tagProperty.stringValue = tag;
            }

            serializedObject.ApplyModifiedProperties();
        }
Exemple #12
0
        internal void OnGUI()
        {
            GUILayout.Space(5);

            var display = alwaysEnabled
                ? EditorGUITools.Header(serializedProperty.displayName, m_SettingsProperty, Reset)
                : EditorGUITools.Header(serializedProperty.displayName, m_SettingsProperty, m_EnabledProperty, Reset);

            if (display)
            {
                EditorGUI.indentLevel++;
                using (new EditorGUI.DisabledGroupScope(!m_EnabledProperty.boolValue))
                {
                    OnInspectorGUI();
                }
                EditorGUI.indentLevel--;
            }
        }
            public ListElement(SerializedProperty property)
            {
                _ListProperty = property;

                _WeightList = EditorGUITools.GetPropertyObject <WeightListBase>(_ListProperty);

                _ValuesProperty  = property.FindPropertyRelative("_Values");
                _WeightsProperty = property.FindPropertyRelative("_Weights");

                list = new ReorderableList(property.serializedObject, _ValuesProperty)
                {
                    drawHeaderCallback    = DrawHeader,
                    elementHeightCallback = ElementHeight,
                    drawElementCallback   = DrawElement,
                    onAddCallback         = OnAdd,
                    onRemoveCallback      = OnRemove,
                    onSelectCallback      = OnSelect,
                    onReorderCallback     = OnReorder,
                };
            }
        void DoGUI(SerializedProperty elementProperty)
        {
            CalculatorCondition.Type type = GetType(elementProperty);

            SerializedProperty parametersProperty = GetParametersProperty(type);

            SerializedProperty parameterIndexProperty = elementProperty.FindPropertyRelative(kParameterIndexPath);

            SerializedProperty parameterProperty = parametersProperty.GetArrayElementAtIndex(parameterIndexProperty.intValue);

            SerializedProperty value1Property = parameterProperty.FindPropertyRelative("value1");
            SerializedProperty value2Property = parameterProperty.FindPropertyRelative("value2");

            switch (type)
            {
            case CalculatorCondition.Type.Int:
            {
                _LayoutArea.PropertyField(elementProperty.FindPropertyRelative("_CompareType"));
                _LayoutArea.PropertyField(value1Property, EditorGUITools.GetTextContent("Int Value 1"));
                _LayoutArea.PropertyField(value2Property, EditorGUITools.GetTextContent("Int Value 2"));
            }
            break;

            case CalculatorCondition.Type.Float:
            {
                _LayoutArea.PropertyField(elementProperty.FindPropertyRelative("_CompareType"));
                _LayoutArea.PropertyField(value1Property, EditorGUITools.GetTextContent("Float Value 1"));
                _LayoutArea.PropertyField(value2Property, EditorGUITools.GetTextContent("Float Value 2"));
            }
            break;

            case CalculatorCondition.Type.Bool:
            {
                _LayoutArea.PropertyField(value1Property, EditorGUITools.GetTextContent("Bool Value 1"));
                _LayoutArea.PropertyField(value2Property, EditorGUITools.GetTextContent("Bool Value 2"));
            }
            break;
            }
        }
            private void DrawElement(Rect rect, int index, bool isActive, bool isFocused)
            {
                if (index == 0)
                {
                    _TotalWeight = _WeightList.GetTotalWeight();
                }

                rect.height = list.elementHeight;

                EditorGUI.LabelField(rect, EditorGUITools.GetTextContent("Element " + index));
                rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;

                SerializedProperty valueProperty = _ValuesProperty.GetArrayElementAtIndex(index);

                if (onPreValueFieldCallback != null)
                {
                    onPreValueFieldCallback(valueProperty);
                }

                GUIContent valueContent = EditorGUITools.GetTextContent("Value");

                rect.height = EditorGUI.GetPropertyHeight(valueProperty, valueContent, true);

                EditorGUI.PropertyField(rect, valueProperty, valueContent);
                rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;

                SerializedProperty weightProperty = _WeightsProperty.GetArrayElementAtIndex(index);

                GUIContent weightContent = EditorGUITools.GetTextContent("Weight");

                rect.height = EditorGUI.GetPropertyHeight(weightProperty, weightContent, true);
                EditorGUI.PropertyField(rect, weightProperty, weightContent);
                rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;

                float probability = (_TotalWeight != 0.0f) ? weightProperty.floatValue / _TotalWeight : 0.0f;

                EditorGUI.LabelField(rect, "Probability", string.Format("{0:P1}", probability));
                rect.y += rect.height + EditorGUIUtility.standardVerticalSpacing;
            }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        if (Event.current.type == EventType.Layout)
        {
            if (_showListA)
            {
                _currentList = _elementListA;
            }
            else
            {
                _currentList = _elementListB;
            }

            if (_removeNext != null)
            {
                _currentList.Remove(_removeNext);
                _removeNext = null;
            }
        }

        Color old = GUI.color;

        if (GUILayout.Button("Set Center"))
        {
            _scrollData.userScrollPosition = 0.5f;
        }

        if (GUILayout.Button("Set bellow"))
        {
            _scrollData.userScrollPosition = 1.0f;
        }

        if (GUILayout.Button("Set 0"))
        {
            _scrollData.userScrollPosition = 0;
        }

        if (_scrollSystemActivated)
        {
            GUI.color = Color.green;
            if (GUILayout.Button("Toggle Scroll System [ENABLED]"))
            {
                _scrollSystemActivated = !_scrollSystemActivated;
            }
        }
        else
        {
            GUI.color = Color.red;
            if (GUILayout.Button("Toggle Scroll System [DISABLED]"))
            {
                _scrollSystemActivated = !_scrollSystemActivated;
            }
        }
        GUI.color = Color.grey;
        if (GUILayout.Button("Toggle List"))
        {
            _showListA = !_showListA;
        }
        GUI.color = old;

        old = GUI.color;


        if (GUILayout.Button("Add element"))
        {
            _currentList.Add(new TestElement("Dynamic Element"));
            _selected = _currentList[_currentList.Count - 1];
            _scrollData.userScrollPosition = 1.0f;
        }

        GUILayout.BeginVertical("HelpBox");
        if (_scrollSystemActivated)
        {
            EditorGUITools.DynamicScroll(this, _scrollData, _currentList,
                                         (element, index) =>
            {
                if (_selected == element)
                {
                    return(128);
                }

                return(28);
            },
                                         (element, index) =>
            {
                if (_selected == element)
                {
                    GUILayout.BeginVertical("HelpBox");
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button(element.text))
                    {
                        _selected = null;
                    }
                    if (GUILayout.Button("X", GUILayout.ExpandWidth(false)))
                    {
                        _removeNext = element;
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.Space(100);
                    GUILayout.EndVertical();
                }
                else
                {
                    GUILayout.BeginHorizontal("HelpBox");
                    if (GUILayout.Button(element.text))
                    {
                        _selected = element;
                    }
                    if (GUILayout.Button("X", GUILayout.ExpandWidth(false)))
                    {
                        _removeNext = element;
                    }
                    GUILayout.EndHorizontal();
                }
            });
        }
        else
        {
            _scrollSize = EditorGUILayout.BeginScrollView(_scrollSize, GUILayout.ExpandHeight(false));

            for (int a = 0; a < _elementListA.Count; ++a)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Button(_elementListA[a].text);
                GUILayout.Button("X", GUILayout.ExpandWidth(false));
                GUILayout.EndVertical();
            }
            EditorGUILayout.EndScrollView();
        }
        GUILayout.EndVertical();

        if (GUILayout.Button("Set Center"))
        {
            _scrollData.userScrollPosition = 0.5f;
        }

        if (GUILayout.Button("Set bellow"))
        {
            _scrollData.userScrollPosition = 1.0f;
        }

        if (GUILayout.Button("Set 0"))
        {
            _scrollData.userScrollPosition = 0;
        }
        GUI.color = old;
    }
        void DeleteOldBranch(Parameter.Type parameterType)
        {
            SerializedProperty valueProperty = null;

            switch (parameterType)
            {
            case Parameter.Type.Int:
            {
                valueProperty = serializedObject.FindProperty("_IntValue");
            }
            break;

            case Parameter.Type.Float:
            {
                valueProperty = serializedObject.FindProperty("_FloatValue");
            }
            break;

            case Parameter.Type.Bool:
            {
                valueProperty = serializedObject.FindProperty("_BoolValue");
            }
            break;

            case Parameter.Type.String:
            {
                valueProperty = serializedObject.FindProperty("_StringValue");
            }
            break;

            case Parameter.Type.GameObject:
            {
                valueProperty = serializedObject.FindProperty("_GameObjectValue");
            }
            break;

            case Parameter.Type.Vector2:
            {
                valueProperty = serializedObject.FindProperty("_Vector2Value");
            }
            break;

            case Parameter.Type.Vector3:
            {
                valueProperty = serializedObject.FindProperty("_Vector3Value");
            }
            break;

            case Parameter.Type.Quaternion:
            {
                valueProperty = serializedObject.FindProperty("_QuaternionValue");
            }
            break;

            case Parameter.Type.Rect:
            {
                valueProperty = serializedObject.FindProperty("_RectValue");
            }
            break;

            case Parameter.Type.Bounds:
            {
                valueProperty = serializedObject.FindProperty("_BoundsValue");
            }
            break;

            case Parameter.Type.Color:
            {
                valueProperty = serializedObject.FindProperty("_ColorValue");
            }
            break;

            case Parameter.Type.Transform:
            {
                valueProperty = serializedObject.FindProperty("_TransformValue");
            }
            break;

            case Parameter.Type.RectTransform:
            {
                valueProperty = serializedObject.FindProperty("_RectTransformValue");
            }
            break;

            case Parameter.Type.Rigidbody:
            {
                valueProperty = serializedObject.FindProperty("_RigidbodyValue");
            }
            break;

            case Parameter.Type.Rigidbody2D:
            {
                valueProperty = serializedObject.FindProperty("_Rigidbody2DValue");
            }
            break;

            case Parameter.Type.Component:
            {
                valueProperty = serializedObject.FindProperty("_ComponentValue");
            }
            break;

            case Parameter.Type.Long:
            {
                valueProperty = serializedObject.FindProperty("_LongValue");
            }
            break;
            }

            if (valueProperty != null)
            {
                foreach (object valueObj in EditorGUITools.GetPropertyObjects(valueProperty))
                {
                    EachField <DataSlot> .Find(valueObj, valueObj.GetType(), (s) =>
                    {
                        s.Disconnect();
                    });
                }
            }
        }
Exemple #18
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            SerializedProperty referenceProperty = serializedObject.FindProperty("_Reference");

            EditorGUILayout.PropertyField(referenceProperty);

            Animator animator = referenceProperty.FindPropertyRelative("animator").objectReferenceValue as Animator;

            if (animator != null && animator.runtimeAnimatorController != null)
            {
                AnimatorController animatorController = animator.runtimeAnimatorController as AnimatorController;

                SerializedProperty nameProperty = referenceProperty.FindPropertyRelative("name");

                AnimatorControllerParameter selectParameter = null;

                foreach (AnimatorControllerParameter parameter in animatorController.parameters)
                {
                    if (parameter.name == nameProperty.stringValue)
                    {
                        selectParameter = parameter;
                        break;
                    }
                }

                if (selectParameter != null)
                {
                    SerializedProperty functionProperty = serializedObject.FindProperty("_Function");

                    switch (selectParameter.type)
                    {
                    case AnimatorControllerParameterType.Float:
                    {
                        EditorGUILayout.PropertyField(functionProperty);
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("_FloatValue"), EditorGUITools.GetTextContent("Float Value"));
                    }
                    break;

                    case AnimatorControllerParameterType.Int:
                    {
                        EditorGUILayout.PropertyField(functionProperty);
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("_IntValue"), EditorGUITools.GetTextContent("Int Value"));
                    }
                    break;

                    case AnimatorControllerParameterType.Bool:
                    {
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("_BoolValue"), EditorGUITools.GetTextContent("Bool Value"));
                    }
                    break;

                    case AnimatorControllerParameterType.Trigger:
                        break;
                    }
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(serializedObject.FindProperty("_Agent"));

            SerializedProperty animatorProperty = serializedObject.FindProperty("_Animator");

            EditorGUILayout.PropertyField(animatorProperty);

            Animator animator = animatorProperty.objectReferenceValue as Animator;

            SerializedProperty movingParameterProperty = serializedObject.FindProperty("_MovingParameter");

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Moving", EditorStyles.boldLabel);
            EditorGUITools.AnimatorParameterField(animator, movingParameterProperty, null, EditorGUITools.GetTextContent(movingParameterProperty.displayName), AnimatorControllerParameterType.Bool);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_MovingSpeedThreshold"));

            SerializedProperty speedParameterProperty = serializedObject.FindProperty("_SpeedParameter");

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Speed", EditorStyles.boldLabel);
            EditorGUITools.AnimatorParameterField(animator, speedParameterProperty, null, EditorGUITools.GetTextContent(speedParameterProperty.displayName), AnimatorControllerParameterType.Float);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_IsDivAgentSpeed"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_SpeedDampTime"));

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Movement", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_MovementType"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_MovementDivValue"));

            SerializedProperty movementXParameterProperty = serializedObject.FindProperty("_MovementXParameter");

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("MovementX", EditorStyles.boldLabel);
            EditorGUITools.AnimatorParameterField(animator, movementXParameterProperty, null, EditorGUITools.GetTextContent(movementXParameterProperty.displayName), AnimatorControllerParameterType.Float);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_MovementXDampTime"));

            SerializedProperty movementYParameterProperty = serializedObject.FindProperty("_MovementYParameter");

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("MovementY", EditorStyles.boldLabel);
            EditorGUITools.AnimatorParameterField(animator, movementYParameterProperty, null, EditorGUITools.GetTextContent(movementYParameterProperty.displayName), AnimatorControllerParameterType.Float);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_MovementYDampTime"));

            SerializedProperty movementZParameterProperty = serializedObject.FindProperty("_MovementZParameter");

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("MovementZ", EditorStyles.boldLabel);
            EditorGUITools.AnimatorParameterField(animator, movementZParameterProperty, null, EditorGUITools.GetTextContent(movementZParameterProperty.displayName), AnimatorControllerParameterType.Float);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_MovementZDampTime"));

            SerializedProperty turnParameterProperty = serializedObject.FindProperty("_TurnParameter");

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Turn", EditorStyles.boldLabel);
            EditorGUITools.AnimatorParameterField(animator, turnParameterProperty, null, EditorGUITools.GetTextContent(turnParameterProperty.displayName), AnimatorControllerParameterType.Float);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_TurnType"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("_TurnDampTime"));

            serializedObject.ApplyModifiedProperties();
        }
Exemple #20
0
    public void OnGUI()
    {
#if DEBUG
        DisplayUnityLogs(460f, 25f, 420f, 505f);
#endif
        if (Singleton <TrainerOptions> .Instance.DisplayTrainerMenu && Singleton <TrainerOptions> .Instance.CheatsEnabled)
        {
            var containerWidth  = 420f;
            var containerHeight = 505f;

            var containerStyle = new GUIStyle(GUI.skin.box)
            {
                padding = new RectOffset(10, 10, 10, 5)
            };

            var horizontalToggleGroupStyle = new GUIStyle(GUI.skin.box)
            {
                padding     = new RectOffset(5, 5, 0, 0),
                fixedHeight = 25f
            };

            var horizontalSliderGroupStyle = new GUIStyle(GUI.skin.box)
            {
                padding = new RectOffset(0, 0, 0, 0),
            };

            var toggleStyle = new GUIStyle(GUI.skin.toggle)
            {
                margin  = new RectOffset(0, 0, 2, 0),
                padding = new RectOffset(15, 0, 3, 2)
            };

            var buttonStyle = new GUIStyle(GUI.skin.button)
            {
                padding = new RectOffset(5, 5, 5, 5)
            };

            var sliderStyle = new GUIStyle()
            {
                padding = new RectOffset(8, 8, 0, 0)
            };

            // Calculate / format frame-rate
            var deltaTimeMs    = this._deltaTime * 1000f;
            var fps            = 1f / this._deltaTime;
            var formattedMsFps = string.Format(" {0:0.0} ms ({1:0} fps)", deltaTimeMs, fps);

            GUILayout.BeginArea(new Rect(25f, 25f, containerWidth, containerHeight), containerStyle);

            GUILayout.BeginHorizontal();
            GUILayout.Label("<color=silver><b>Stick Fight The Game</b></color>", new GUIStyle {
                alignment = TextAnchor.MiddleLeft
            });
            GUILayout.Label("<color=maroon><b>" + formattedMsFps + "</b></color>", new GUIStyle {
                alignment = TextAnchor.MiddleRight
            });
            GUILayout.EndHorizontal();

            GUILayout.Label("<color=silver><b>+12 Trainer v{Application.ProductVersion} - Made by loxa</b></color>");
            GUILayout.Space(5);
            GUILayout.Label("<color=grey><b>Toggle Options</b></color>");

            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();

            // Toggle between 'Public (no-cheats)' and 'Modders-only (cheats)' mode
            if (GUILayout.Toggle(Singleton <TrainerOptions> .Instance.TrainerActive, "<color=green> " + (Singleton <TrainerOptions> .Instance.TrainerActive ? "Modders Mode" : "Public Mode") + "</color>", GUILayout.Width(140)) != Singleton <TrainerOptions> .Instance.TrainerActive)
            {
                // Announce restart due to online mode change
                MultiplayerManager.mGameManager.winText.fontSize = 140f;
                MultiplayerManager.mGameManager.winText.color    = Color.white;
                MultiplayerManager.mGameManager.winText.text     = (!Singleton <TrainerOptions> .Instance.TrainerActive
                    ? "MODDERS ONLY - CHEATS ENABLED\r\nRestarting in 2 seconds..."
                    : "PUBLIC - CHEATS DISABLED\r\nRestarting in 2 seconds...");

                MultiplayerManager.mGameManager.winText.gameObject.SetActive(true);

                // Toggle trainer active state
                Singleton <TrainerOptions> .Instance.TrainerActive = !Singleton <TrainerOptions> .Instance.TrainerActive;

                // Provide time for the announcement text to appear and be read
                StartCoroutine(Wait(2f));

                // Restart game and switch lobby type
                MultiplayerManager.mGameManager.RestartGame();
                MatchmakingHandler.SetNewLobbyType(ELobbyType.k_ELobbyTypePrivate);
            }

            // Toggle flying mode for all players
            if (GUILayout.Toggle(Singleton <TrainerOptions> .Instance.FlightMode, " Flying Mode", GUILayout.Width(140)) != Singleton <TrainerOptions> .Instance.FlightMode)
            {
                Singleton <TrainerOptions> .Instance.FlightMode = !Singleton <TrainerOptions> .Instance.FlightMode;
                ToggleFlyingMode();
            }

            // Toggle uncapped fire-rate
            if (GUILayout.Toggle(Singleton <TrainerOptions> .Instance.UncappedFirerate, " Uncapped Fire-rate", GUILayout.Width(140)) != Singleton <TrainerOptions> .Instance.UncappedFirerate)
            {
                Singleton <TrainerOptions> .Instance.UncappedFirerate = !Singleton <TrainerOptions> .Instance.UncappedFirerate;
                ToggleUncappedFirerate();
            }

            GUILayout.EndVertical();

            GUILayout.BeginVertical();

            // Toggle display of health bars
            if (GUILayout.Toggle(Singleton <TrainerOptions> .Instance.DisplayHealthBars, " Health Bars", GUILayout.Width(130)) != Singleton <TrainerOptions> .Instance.DisplayHealthBars)
            {
                Singleton <TrainerOptions> .Instance.DisplayHealthBars = !Singleton <TrainerOptions> .Instance.DisplayHealthBars;
            }

            // Toggle full automatic weapons
            if (GUILayout.Toggle(Singleton <TrainerOptions> .Instance.FullAuto, " Full Auto", GUILayout.Width(130)) != Singleton <TrainerOptions> .Instance.FullAuto)
            {
                Singleton <TrainerOptions> .Instance.FullAuto = !Singleton <TrainerOptions> .Instance.FullAuto;
                ToggleFullAuto();
            }

            // Toggle unlimited ammunition
            if (GUILayout.Toggle(Singleton <TrainerOptions> .Instance.UnlimitedAmmo, " Unlimited Ammo", GUILayout.Width(130)) != Singleton <TrainerOptions> .Instance.UnlimitedAmmo)
            {
                Singleton <TrainerOptions> .Instance.UnlimitedAmmo = !Singleton <TrainerOptions> .Instance.UnlimitedAmmo;
                ToggleUnlimitedAmmo();
            }

            GUILayout.EndVertical();

            GUILayout.BeginVertical();

            // Toggle display of scoreboard
            if (GUILayout.Toggle(Singleton <TrainerOptions> .Instance.DisplayScore, " Scoreboard", GUILayout.Width(150)) != Singleton <TrainerOptions> .Instance.DisplayScore)
            {
                Singleton <TrainerOptions> .Instance.DisplayScore = !Singleton <TrainerOptions> .Instance.DisplayScore;
            }

            // Toggle no recoil
            if (GUILayout.Toggle(Singleton <TrainerOptions> .Instance.NoRecoil, " No Recoil", GUILayout.Width(150)) != Singleton <TrainerOptions> .Instance.NoRecoil)
            {
                Singleton <TrainerOptions> .Instance.NoRecoil = !Singleton <TrainerOptions> .Instance.NoRecoil;
                ToggleNoRecoil();
            }

            // Toggle unlimited health
            if (GUILayout.Toggle(Singleton <TrainerOptions> .Instance.UnlimitedHealth, " Unlimited Health", GUILayout.Width(150)) != Singleton <TrainerOptions> .Instance.UnlimitedHealth)
            {
                // Handled in the patched TakeDamage method
                Singleton <TrainerOptions> .Instance.UnlimitedHealth = !Singleton <TrainerOptions> .Instance.UnlimitedHealth;
            }

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            GUILayout.Label("<color=grey><b>Spawn Bots</b></color>");

            GUILayout.BeginHorizontal();

            GUILayout.BeginHorizontal(horizontalToggleGroupStyle, GUILayout.Width(100));
            if (GUILayout.Toggle(Singleton <TrainerOptions> .Instance.SpawnPcEnabled, " PC", toggleStyle, GUILayout.Width(50)) != Singleton <TrainerOptions> .Instance.SpawnPcEnabled)
            {
                Singleton <TrainerOptions> .Instance.SpawnPcEnabled = !Singleton <TrainerOptions> .Instance.SpawnPcEnabled;
            }
            if (GUILayout.Toggle(Singleton <TrainerOptions> .Instance.SpawnNpcEnabled, " NPC", toggleStyle, GUILayout.Width(50)) != Singleton <TrainerOptions> .Instance.SpawnNpcEnabled)
            {
                Singleton <TrainerOptions> .Instance.SpawnNpcEnabled = !Singleton <TrainerOptions> .Instance.SpawnNpcEnabled;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(horizontalToggleGroupStyle, GUILayout.Width(170));
            if (GUILayout.Toggle(Singleton <TrainerOptions> .Instance.AiAggressiveEnabled, " Aggressive", toggleStyle, GUILayout.Width(95)) != Singleton <TrainerOptions> .Instance.AiAggressiveEnabled)
            {
                Singleton <TrainerOptions> .Instance.AiAggressiveEnabled = !Singleton <TrainerOptions> .Instance.AiAggressiveEnabled;
            }
            if (GUILayout.Toggle(Singleton <TrainerOptions> .Instance.AiNormalEnabled, " Normal", toggleStyle, GUILayout.Width(60)) != Singleton <TrainerOptions> .Instance.AiNormalEnabled)
            {
                Singleton <TrainerOptions> .Instance.AiNormalEnabled = !Singleton <TrainerOptions> .Instance.AiNormalEnabled;
            }
            GUILayout.EndHorizontal();

            GUILayout.EndHorizontal();
            GUILayout.Space(3);

            GUILayout.BeginHorizontal(horizontalSliderGroupStyle);

            GUILayout.BeginVertical(sliderStyle);
            GUILayout.Label("Damage");
            var aiDamageMultiplier = GUILayout.HorizontalSlider(Singleton <TrainerOptions> .Instance.AiDamageMultiplier, 1f, 5f);
            if (aiDamageMultiplier != Singleton <TrainerOptions> .Instance.AiDamageMultiplier)
            {
                Singleton <TrainerOptions> .Instance.AiDamageMultiplier = aiDamageMultiplier;
                SetBotStats();
            }
            GUILayout.EndVertical();

            GUILayout.BeginVertical(sliderStyle);
            GUILayout.Label("Punch Force");
            var aiPunchForce = GUILayout.HorizontalSlider(Singleton <TrainerOptions> .Instance.AiPunchForce, 120000f, 800000f);
            if (aiPunchForce != Singleton <TrainerOptions> .Instance.AiPunchForce)
            {
                Singleton <TrainerOptions> .Instance.AiPunchForce = aiPunchForce;
                SetBotStats();
            }
            GUILayout.EndVertical();

            GUILayout.BeginVertical(sliderStyle);
            GUILayout.Label("Punch Time");
            var aiPunchTime = GUILayout.HorizontalSlider(Singleton <TrainerOptions> .Instance.AiPunchTime, 0.1f, 0.50f);
            if (aiPunchTime != Singleton <TrainerOptions> .Instance.AiPunchTime)
            {
                Singleton <TrainerOptions> .Instance.AiPunchTime = aiPunchTime;
                SetBotStats();
            }
            GUILayout.EndVertical();

            GUILayout.BeginVertical(sliderStyle);
            GUILayout.Label("Speed");
            var aiMovementForceMultiplier = GUILayout.HorizontalSlider(Singleton <TrainerOptions> .Instance.AiMovementForceMultiplier, 2000f, 6000f);
            if (aiMovementForceMultiplier != Singleton <TrainerOptions> .Instance.AiMovementForceMultiplier)
            {
                Singleton <TrainerOptions> .Instance.AiMovementForceMultiplier = aiMovementForceMultiplier;
                SetBotStats();
            }
            GUILayout.EndVertical();

            GUILayout.BeginVertical(sliderStyle);
            GUILayout.Label("Jump Height");
            var aiMovementJumpForceMultiplier = GUILayout.HorizontalSlider(Singleton <TrainerOptions> .Instance.AiMovementJumpForceMultiplier, 25f, 100f);
            if (aiMovementJumpForceMultiplier != Singleton <TrainerOptions> .Instance.AiMovementJumpForceMultiplier)
            {
                Singleton <TrainerOptions> .Instance.AiMovementJumpForceMultiplier = aiMovementJumpForceMultiplier;
                SetBotStats();
            }
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();
            GUILayout.Space(3);

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Player", buttonStyle, GUILayout.Width(75)))
            {
                SpawnBotEnemyPlayer();
            }

            if (GUILayout.Button("Zombie", buttonStyle, GUILayout.Width(75)))
            {
                SpawnBotEnemyZombie();
            }

            if (GUILayout.Button("Bolt", buttonStyle, GUILayout.Width(75)))
            {
                SpawnBotEnemyBrat();
            }

            GUILayout.EndHorizontal();

            // Display available shortcuts

            GUILayout.Space(10);
            GUILayout.Label("<color=grey><b>PC Keyboard Shortcuts</b></color>");
            GUILayout.Label("- Toggle Menu:\t[SHIFT] + [M]\r\n" +
                            "- Skip Map:\t[SHIFT] + [S]\r\n" +
                            "- Spawn Weapon:\t[R] or [P]\r\n" +
                            "- Browse Weapons:\t[Q] for previous or [E] for next");

            GUILayout.Space(5);
            GUILayout.Label("<color=grey><b>Xbox 360 Controller Shortcuts</b></color>");
            GUILayout.Label("- Toggle Menu:\t[RB] + [A]\r\n" +
                            "- Skip Map:\t[RB] + [B]\r\n" +
                            "- Spawn Weapon:\t[DPadUp] or [DPadDown]\r\n" +
                            "- Browse Weapons:\t[DPadLeft] or [DPadRight]");

            GUILayout.EndArea();
        }

        if (Singleton <TrainerOptions> .Instance.CheatsEnabled)
        {
            if (MultiplayerManager.mGameManager != null && MultiplayerManager.mGameManager.controllerHandler != null && MultiplayerManager.mGameManager.controllerHandler.players != null)
            {
                // Display healthbars and scores for all players
                foreach (var player in MultiplayerManager.mGameManager.controllerHandler.players)
                {
                    if (player != null && player.fighting != null)
                    {
                        if (Singleton <TrainerOptions> .Instance.DisplayHealthBars)
                        {
                            var health        = 0f;
                            var healthHandler = player.fighting.GetComponent <HealthHandler>();
                            if (healthHandler != null)
                            {
                                health = healthHandler.health;
                            }

                            EditorGUITools.DrawRect(new Rect(Screen.width - 125, 30f * player.playerID + 10f, Math.Max(0f, health), 20f), GetPlayerColorByIndex(player.playerID), null);
                            GUI.Label(new Rect(Screen.width - 160, 30f * player.playerID + 10f, 250f, 25f), Math.Max(0.0, Math.Round(health)).ToString());
                        }

                        if (Singleton <TrainerOptions> .Instance.DisplayScore && player.fighting.stats != null)
                        {
                            GUI.Label(new Rect(Screen.width - 180, 30f * (float)player.playerID + 10f, 250f, 25f), "<b>" + player.fighting.stats.wins.ToString() + "</b>");
                        }
                    }
                }
            }
        }
    }
Exemple #21
0
    public static void DrawNPC(SerializedProperty character, SerializedObject serializedObject)
    {
        SerializedProperty stats = character.FindPropertyRelative("inspectorStats");
        SerializedProperty needs = character.FindPropertyRelative("inspectorNeeds");
        SerializedProperty wants = character.FindPropertyRelative("inspectorWants");

        SerializedProperty firstName  = character.FindPropertyRelative("firstName");
        SerializedProperty middleName = character.FindPropertyRelative("middleName");
        SerializedProperty lastName   = character.FindPropertyRelative("lastName");

        firstName.stringValue  = EditorGUILayout.TextField("First Name", firstName.stringValue);
        middleName.stringValue = EditorGUILayout.TextField("Middle Name", middleName.stringValue);
        lastName.stringValue   = EditorGUILayout.TextField("Last Name", lastName.stringValue);


        GUILayout.Space(5f);


        if (EditorGUITools.DrawHeader("Stats (" + stats.arraySize + "):", "ShowStats"))
        {
            GUILayout.BeginVertical(EditorStyles.numberField);
            GUILayout.Space(5);


            GUILayout.BeginHorizontal();
            GUILayout.Label("Name:");
            GUILayout.Label("Value:");
            GUILayout.EndHorizontal();

            for (int i = 0, n = stats.arraySize; i < n; i++)
            {
                GUILayout.BeginVertical();


                SerializedProperty stat      = stats.GetArrayElementAtIndex(i);
                SerializedProperty statName  = stat.FindPropertyRelative("name");
                SerializedProperty statValue = stat.FindPropertyRelative("value");

                // Name, value, delete
                GUILayout.BeginHorizontal();


                statName.stringValue = GUILayout.TextField(statName.stringValue, GUILayout.MinWidth(75));
                statValue.floatValue = EditorGUILayout.FloatField(statValue.floatValue);

                if (GUILayout.Button("X", GUILayout.Width(25)))
                {
                    stats.DeleteArrayElementAtIndex(i); i = n;
                }

                GUILayout.EndHorizontal();


                GUILayout.EndVertical();
            }

            if (GUILayout.Button("Add Stat", EditorStyles.toolbarButton))
            {
                stats.InsertArrayElementAtIndex(stats.arraySize);
            }

            GUILayout.EndVertical();
        }


        #region Needs
        if (EditorGUITools.DrawHeader("Needs (" + needs.arraySize + "):", "ShowNeeds"))
        {
            GUILayout.BeginVertical(EditorStyles.numberField);
            GUILayout.Space(5);

            for (int i = 0, n = needs.arraySize; i < n; i++)
            {
                // Get the variables from the need
                SerializedProperty need     = needs.GetArrayElementAtIndex(i);
                SerializedProperty needName = need.FindPropertyRelative("name");


                if (EditorGUITools.DrawHeader(needName.stringValue, needName.stringValue + "_menu"))
                {
                    SerializedProperty needPriority      = need.FindPropertyRelative("priority");
                    SerializedProperty priorityModifiers = need.FindPropertyRelative("priorityModifiers");
                    SerializedProperty actions           = need.FindPropertyRelative("actions");


                    GUI.color = new Color(0.4f, 0.4f, 0.4f);
                    GUILayout.BeginVertical(EditorStyles.numberField);
                    GUI.color = Color.white;

                    GUILayout.Space(10);

                    // Name, value, priority
                    GUILayout.BeginHorizontal();

                    GUILayout.Label("Name:");
                    needName.stringValue = GUILayout.TextField(needName.stringValue, GUILayout.MinWidth(75));


                    GUILayout.Label("Priority: " + needPriority.intValue);

                    if (GUILayout.Button("X", GUILayout.Width(25), GUILayout.Height(15)))
                    {
                        needs.DeleteArrayElementAtIndex(i); i = n; continue;
                    }

                    GUILayout.EndHorizontal();

                    GUILayout.Space(10);


                    // Show modifiers
                    if (EditorGUITools.DrawHeader("Priority Modifiers (" + priorityModifiers.arraySize + "):", needName.stringValue + "_priority"))
                    {
                        GUILayout.BeginVertical(EditorStyles.numberField);

                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Name:");
                        GUILayout.Label("Value:");
                        GUILayout.EndHorizontal();



                        for (int k = 0, m = priorityModifiers.arraySize; k < m; k++)
                        {
                            SerializedProperty modifier      = priorityModifiers.GetArrayElementAtIndex(k);
                            SerializedProperty modifierName  = modifier.FindPropertyRelative("name");
                            SerializedProperty modifierValue = modifier.FindPropertyRelative("value");

                            // Name, value, delete
                            GUILayout.BeginHorizontal();


                            modifierName.stringValue = GUILayout.TextField(modifierName.stringValue, GUILayout.MinWidth(75));

                            modifierValue.animationCurveValue = EditorGUILayout.CurveField(modifierValue.animationCurveValue);

                            if (GUILayout.Button("X", GUILayout.Width(25)))
                            {
                                priorityModifiers.DeleteArrayElementAtIndex(k); k = m;
                            }

                            GUILayout.EndHorizontal();
                        }

                        if (GUILayout.Button("Add Modifier", EditorStyles.toolbarButton))
                        {
                            priorityModifiers.InsertArrayElementAtIndex(priorityModifiers.arraySize);
                        }

                        GUILayout.EndVertical();
                    }


                    GUILayout.Space(5);

                    // Show Actions TODO
                    if (EditorGUITools.DrawHeader("Actions(" + actions.arraySize + "):", needName.stringValue + "_actions"))
                    {
                    }


                    GUILayout.EndVertical();

                    if (i != n - 1)
                    {
                        GUILayout.Space(10);
                    }
                }
            }


            GUILayout.Space(5);
            if (GUILayout.Button("Add Need", EditorStyles.toolbarButton))
            {
                needs.InsertArrayElementAtIndex(needs.arraySize);
            }

            GUILayout.EndVertical();
        }
        #endregion

        #region Wants
        if (EditorGUITools.DrawHeader("Wants (" + wants.arraySize + "):", "ShowWants"))
        {
            GUILayout.BeginVertical(EditorStyles.numberField);
            GUILayout.Space(5);

            for (int i = 0, n = wants.arraySize; i < n; i++)
            {
                // Get the variables from the wants
                SerializedProperty want     = wants.GetArrayElementAtIndex(i);
                SerializedProperty wantName = want.FindPropertyRelative("name");


                if (EditorGUITools.DrawHeader(wantName.stringValue, wantName.stringValue + "_menu"))
                {
                    SerializedProperty wantPriority      = want.FindPropertyRelative("priority");
                    SerializedProperty priorityModifiers = want.FindPropertyRelative("priorityModifiers");
                    SerializedProperty actions           = want.FindPropertyRelative("actions");


                    GUI.color = new Color(0.4f, 0.4f, 0.4f);
                    GUILayout.BeginVertical(EditorStyles.numberField);
                    GUI.color = Color.white;

                    GUILayout.Space(10);

                    // Name, value, priority
                    GUILayout.BeginHorizontal();

                    GUILayout.Label("Name:");
                    wantName.stringValue = GUILayout.TextField(wantName.stringValue, GUILayout.MinWidth(75));


                    GUILayout.Label("Priority: " + wantPriority.intValue);

                    if (GUILayout.Button("X", GUILayout.Width(25), GUILayout.Height(15)))
                    {
                        wants.DeleteArrayElementAtIndex(i); i = n; continue;
                    }

                    GUILayout.EndHorizontal();

                    GUILayout.Space(10);


                    // Show modifiers
                    if (EditorGUITools.DrawHeader("Priority Modifiers (" + priorityModifiers.arraySize + "):", wantName.stringValue + "_priority"))
                    {
                        GUILayout.BeginVertical(EditorStyles.numberField);

                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Name:");
                        GUILayout.Label("Value:");
                        GUILayout.EndHorizontal();



                        for (int k = 0, m = priorityModifiers.arraySize; k < m; k++)
                        {
                            SerializedProperty modifier      = priorityModifiers.GetArrayElementAtIndex(k);
                            SerializedProperty modifierName  = modifier.FindPropertyRelative("name");
                            SerializedProperty modifierValue = modifier.FindPropertyRelative("value");

                            // Name, value, delete
                            GUILayout.BeginHorizontal();


                            modifierName.stringValue = GUILayout.TextField(modifierName.stringValue, GUILayout.MinWidth(75));

                            modifierValue.animationCurveValue = EditorGUILayout.CurveField(modifierValue.animationCurveValue);

                            if (GUILayout.Button("X", GUILayout.Width(25)))
                            {
                                priorityModifiers.DeleteArrayElementAtIndex(k); k = m;
                            }

                            GUILayout.EndHorizontal();
                        }

                        if (GUILayout.Button("Add Modifier", EditorStyles.toolbarButton))
                        {
                            priorityModifiers.InsertArrayElementAtIndex(priorityModifiers.arraySize);
                        }

                        GUILayout.EndVertical();
                    }


                    GUILayout.Space(5);

                    // Show Actions TODO
                    if (EditorGUITools.DrawHeader("Actions(" + actions.arraySize + "):", wantName.stringValue + "_actions"))
                    {
                    }


                    GUILayout.EndVertical();

                    if (i != n - 1)
                    {
                        GUILayout.Space(10);
                    }
                }
            }


            GUILayout.Space(5);
            if (GUILayout.Button("Add Want", EditorStyles.toolbarButton))
            {
                wants.InsertArrayElementAtIndex(wants.arraySize);
            }

            GUILayout.EndVertical();
        }
        #endregion


        GUILayout.Space(5f);

        serializedObject.ApplyModifiedProperties();
    }
        private void ConditionGUI(ParameterConditionLegacyProperty conditionProperty)
        {
            Parameter.Type parameterType = conditionProperty.GetParameterType();

            SerializedProperty compareTypeProperty = conditionProperty.compareTypeProperty;

            switch (parameterType)
            {
            case Parameter.Type.Int:
            {
                _LayoutArea.PropertyField(compareTypeProperty);
                _LayoutArea.PropertyField(conditionProperty.intValueProperty, EditorGUITools.GetTextContent("Int Value"));
            }
            break;

            case Parameter.Type.Long:
            {
                _LayoutArea.PropertyField(compareTypeProperty);
                _LayoutArea.PropertyField(conditionProperty.longValueProperty, EditorGUITools.GetTextContent("Long Value"));
            }
            break;

            case Parameter.Type.Float:
            {
                _LayoutArea.PropertyField(compareTypeProperty);
                _LayoutArea.PropertyField(conditionProperty.floatValueProperty, EditorGUITools.GetTextContent("Float Value"));
            }
            break;

            case Parameter.Type.Bool:
            {
                _LayoutArea.PropertyField(conditionProperty.boolValueProperty, EditorGUITools.GetTextContent("Bool Value"));
            }
            break;

            case Parameter.Type.String:
            {
                _LayoutArea.PropertyField(compareTypeProperty);
                _LayoutArea.PropertyField(conditionProperty.stringValueProperty, EditorGUITools.GetTextContent("String Value"));
            }
            break;

            case Parameter.Type.GameObject:
            {
                _LayoutArea.PropertyField(conditionProperty.gameObjectValueProperty, EditorGUITools.GetTextContent("GameObject Value"));
            }
            break;

            case Parameter.Type.Vector2:
            {
                _LayoutArea.PropertyField(conditionProperty.vector2ValueProperty, EditorGUITools.GetTextContent("Vector2 Value"));
            }
            break;

            case Parameter.Type.Vector3:
            {
                _LayoutArea.PropertyField(conditionProperty.vector3ValueProperty, EditorGUITools.GetTextContent("Vector3 Value"));
            }
            break;

            case Parameter.Type.Quaternion:
            {
                _LayoutArea.PropertyField(conditionProperty.quaternionValueProperty, EditorGUITools.GetTextContent("Quaternion Value"));
            }
            break;

            case Parameter.Type.Rect:
            {
                _LayoutArea.PropertyField(conditionProperty.rectValueProperty, EditorGUITools.GetTextContent("Rect Value"));
            }
            break;

            case Parameter.Type.Bounds:
            {
                _LayoutArea.PropertyField(conditionProperty.boundsValueProperty, EditorGUITools.GetTextContent("Bounds Value"));
            }
            break;

            case Parameter.Type.Color:
            {
                _LayoutArea.PropertyField(conditionProperty.colorValueProperty, EditorGUITools.GetTextContent("Color Value"));
            }
            break;

            case Parameter.Type.Transform:
            {
                _LayoutArea.PropertyField(conditionProperty.transformValueProperty, EditorGUITools.GetTextContent("Transform Value"));
            }
            break;

            case Parameter.Type.RectTransform:
            {
                _LayoutArea.PropertyField(conditionProperty.rectTransformValueProperty, EditorGUITools.GetTextContent("RectTransform Value"));
            }
            break;

            case Parameter.Type.Rigidbody:
            {
                _LayoutArea.PropertyField(conditionProperty.rigidbodyValueProperty, EditorGUITools.GetTextContent("Rigidbody Value"));
            }
            break;

            case Parameter.Type.Rigidbody2D:
            {
                _LayoutArea.PropertyField(conditionProperty.rigidbody2DValueProperty, EditorGUITools.GetTextContent("Rigidbody2D Value"));
            }
            break;

            case Parameter.Type.Component:
            {
                SerializedProperty componentValueProperty = conditionProperty.componentValueProperty;
                componentValueProperty.SetStateData(conditionProperty.GetReferenceType());

                _LayoutArea.PropertyField(componentValueProperty, EditorGUITools.GetTextContent("Component Value"));
            }
            break;

            case Parameter.Type.Enum:
            {
                SerializedProperty enumValueProperty = conditionProperty.enumValueProperty;
                enumValueProperty.SetStateData(conditionProperty.GetReferenceType());

                _LayoutArea.PropertyField(enumValueProperty, EditorGUITools.GetTextContent("Enum Value"));
            }
            break;

            case Parameter.Type.Variable:
            {
                Parameter parameter     = conditionProperty.referenceProperty.GetParameter();
                string    valueTypeName = (parameter != null && parameter.valueType != null) ? parameter.valueType.ToString() : "Variable";
                string    message       = string.Format(Localization.GetWord("ParameterCondition.NotSupportVariable"), valueTypeName);

                _LayoutArea.HelpBox(message, MessageType.Warning);
            }
            break;
            }
        }
Exemple #23
0
        void DoGUI(GUIContent label)
        {
            EditorGUI.BeginProperty(_LayoutArea.rect, label, property);

            int indentLevel = EditorGUI.indentLevel;

            if (label != GUIContent.none)
            {
                _LayoutArea.LabelField(label);
                EditorGUI.indentLevel++;
            }

            SendMessageArgument.Type argumentType = _ArgumentProperty.type;

            EditorGUI.BeginChangeCheck();
            _LayoutArea.PropertyField(_ArgumentProperty.typeProperty);
            if (EditorGUI.EndChangeCheck() && _ArgumentProperty.type != argumentType)
            {
                _ArgumentProperty.Disconnect(argumentType);

                argumentType = _ArgumentProperty.type;

                if (argumentType == SendMessageArgument.Type.Enum ||
                    argumentType == SendMessageArgument.Type.Component)
                {
                    _ArgumentProperty.referenceTypeProperty.Clear();
                }
                else if (argumentType == SendMessageArgument.Type.Slot)
                {
                    _ArgumentProperty.inputSlotValueProperty.Clear();
                }
            }

            SerializedProperty valueProperty = _ArgumentProperty.GetValueProperty(argumentType);

            if (valueProperty != null)
            {
                switch (argumentType)
                {
                case SendMessageArgument.Type.Enum:
                    _ArgumentProperty.referenceTypeProperty.property.SetStateData <ClassTypeConstraintAttribute>(ClassTypeConstraintEditorUtility.enumField);
                    _LayoutArea.PropertyField(_ArgumentProperty.referenceTypeProperty.property);

                    valueProperty.SetStateData(_ArgumentProperty.referenceTypeProperty.type);
                    break;

                case SendMessageArgument.Type.Component:
                    _ArgumentProperty.referenceTypeProperty.property.SetStateData <ClassTypeConstraintAttribute>(ClassTypeConstraintEditorUtility.component);
                    _LayoutArea.PropertyField(_ArgumentProperty.referenceTypeProperty.property);

                    valueProperty.SetStateData(_ArgumentProperty.referenceTypeProperty.type);
                    break;

                case SendMessageArgument.Type.Slot:
                    _LayoutArea.PropertyField(_ArgumentProperty.inputSlotValueProperty.typeProperty.property, EditorGUITools.GetTextContent("Reference Type"));
                    break;
                }
                _LayoutArea.PropertyField(valueProperty);
            }

            EditorGUI.indentLevel = indentLevel;

            EditorGUI.EndProperty();
        }
        void DeleteOldBranch(ParameterConditionLegacyProperty conditionProperty, Parameter.Type type)
        {
            SerializedProperty valueProperty = null;

            switch (type)
            {
            case Parameter.Type.Int:
            {
                valueProperty = conditionProperty.intValueProperty;
            }
            break;

            case Parameter.Type.Long:
            {
                valueProperty = conditionProperty.longValueProperty;
            }
            break;

            case Parameter.Type.Float:
            {
                valueProperty = conditionProperty.floatValueProperty;
            }
            break;

            case Parameter.Type.Bool:
            {
                valueProperty = conditionProperty.boolValueProperty;
            }
            break;

            case Parameter.Type.String:
            {
                valueProperty = conditionProperty.stringValueProperty;
            }
            break;

            case Parameter.Type.GameObject:
            {
                valueProperty = conditionProperty.gameObjectValueProperty;
            }
            break;

            case Parameter.Type.Vector2:
            {
                valueProperty = conditionProperty.vector2ValueProperty;
            }
            break;

            case Parameter.Type.Vector3:
            {
                valueProperty = conditionProperty.vector3ValueProperty;
            }
            break;

            case Parameter.Type.Quaternion:
            {
                valueProperty = conditionProperty.quaternionValueProperty;
            }
            break;

            case Parameter.Type.Rect:
            {
                valueProperty = conditionProperty.rectValueProperty;
            }
            break;

            case Parameter.Type.Bounds:
            {
                valueProperty = conditionProperty.boundsValueProperty;
            }
            break;

            case Parameter.Type.Color:
            {
                valueProperty = conditionProperty.colorValueProperty;
            }
            break;

            case Parameter.Type.Transform:
            {
                valueProperty = conditionProperty.transformValueProperty;
            }
            break;

            case Parameter.Type.RectTransform:
            {
                valueProperty = conditionProperty.rectTransformValueProperty;
            }
            break;

            case Parameter.Type.Rigidbody:
            {
                valueProperty = conditionProperty.rigidbodyValueProperty;
            }
            break;

            case Parameter.Type.Rigidbody2D:
            {
                valueProperty = conditionProperty.rigidbody2DValueProperty;
            }
            break;

            case Parameter.Type.Component:
            {
                valueProperty = conditionProperty.componentValueProperty;
            }
            break;
            }

            if (valueProperty != null)
            {
                foreach (object valueObj in EditorGUITools.GetPropertyObjects(valueProperty))
                {
                    EachField <DataSlot> .Find(valueObj, valueObj.GetType(), (s) =>
                    {
                        s.Disconnect();
                    });
                }
            }
        }