Ejemplo n.º 1
0
    public float TestRecentering(float minValue, float maxValue, bool wrap,
                                 float maxSpeed, float accelTime, float decelTime, bool invert, float axisValue,
                                 bool enabled, float recenteringTime)
    {
        var axisState = new AxisState(minValue, maxValue, false, false, maxSpeed, accelTime, decelTime, null, invert);

        axisState.SetInputAxisProvider(0, new TestAxisProvider(axisValue));
        axisState.Validate();

        var success = axisState.Update(1.0f);

        Assert.IsTrue(success, "Update had no effect");

        var recentering = new AxisState.Recentering(enabled, 0.0f, recenteringTime);

        recentering.DoRecentering(ref axisState, 10.0f, 0.0f);

        return(axisState.Value < Cinemachine.Utility.UnityVectorExtensions.Epsilon ? 0f : axisState.Value);
    }
Ejemplo n.º 2
0
        AxisState def    = new AxisState(); // to access name strings

        public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
        {
            float height = EditorGUIUtility.singleLineHeight;

            rect.height = height;
            mExpanded   = EditorGUI.Foldout(rect, mExpanded, EditorGUI.BeginProperty(rect, label, property), true);
            if (mExpanded)
            {
                ++EditorGUI.indentLevel;

                rect.y += height + vSpace;
                EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.Value));

                if (!ValueRangeIsLocked(property))
                {
                    rect.y += height + vSpace;
                    InspectorUtility.MultiPropertyOnLine(rect, new GUIContent("Value Range"),
                                                         new [] { property.FindPropertyRelative(() => def.m_MinValue),
                                                                  property.FindPropertyRelative(() => def.m_MaxValue),
                                                                  property.FindPropertyRelative(() => def.m_Wrap) },
                                                         new [] { GUIContent.none, new GUIContent("to "), null });
                }

                rect.y += height + vSpace;
                InspectorUtility.MultiPropertyOnLine(rect, new GUIContent("Speed"),
                                                     new [] { property.FindPropertyRelative(() => def.m_MaxSpeed),
                                                              property.FindPropertyRelative(() => def.m_SpeedMode) },
                                                     new [] { GUIContent.none, new GUIContent("as") });

                rect.y += height + vSpace;
                InspectorUtility.MultiPropertyOnLine(
                    rect, null,
                    new [] { property.FindPropertyRelative(() => def.m_AccelTime),
                             property.FindPropertyRelative(() => def.m_DecelTime) },
                    new [] { GUIContent.none, null });

                if (HasRecentering(property))
                {
                    var rDef        = new AxisState.Recentering();
                    var recentering = property.FindPropertyRelative(() => def.m_Recentering);
                    rect.y += height + vSpace;
                    InspectorUtility.MultiPropertyOnLine(
                        rect, new GUIContent(recentering.displayName, recentering.tooltip),
                        new [] {
                        recentering.FindPropertyRelative(() => rDef.m_enabled),
                        recentering.FindPropertyRelative(() => rDef.m_WaitTime),
                        recentering.FindPropertyRelative(() => rDef.m_RecenteringTime)
                    },
                        new [] { new GUIContent(""),
                                 new GUIContent("Wait"),
                                 new GUIContent("Time") });
                }

                if (!HasInputProvider(property))
                {
                    rect.y += height + vSpace;
                    EditorGUI.PropertyField(
                        rect, property.FindPropertyRelative(() => def.m_InputAxisName));
                }

                rect.y += height + vSpace;
                InspectorUtility.MultiPropertyOnLine(rect, null,
                                                     new [] { property.FindPropertyRelative(() => def.m_InputAxisValue),
                                                              property.FindPropertyRelative(() => def.m_InvertInput) },
                                                     new [] { GUIContent.none, new GUIContent("Invert") });

                --EditorGUI.indentLevel;
            }
        }