Esempio n. 1
0
 protected void Update()
 {
     if (_animation == null || _curve1JSON == null || _curveEditor == null)
     {
         return;
     }
     if (_animation.isPlaying)
     {
         var state = _animation["CurveEditorDemo"];
         if (state != null)
         {
             _curveEditor.SetScrubberPosition(state.time % _curve1JSON.val[_curve1JSON.val.length - 1].time);
         }
     }
 }
        public float Evaluate(float[] xTarget, float[] rTarget)
        {
            var t = 0.0f;

            if (CurveXAxisChooser.val == "L0")
            {
                t = Mathf.Clamp01(xTarget[0]);
            }
            else if (CurveXAxisChooser.val == "L1")
            {
                t = xTarget[1];
            }
            else if (CurveXAxisChooser.val == "L2")
            {
                t = xTarget[2];
            }
            else if (CurveXAxisChooser.val == "L1+L2")
            {
                t = Mathf.Clamp01(Mathf.Sqrt(xTarget[1] * xTarget[1] + xTarget[2] * xTarget[2]));
            }
            else if (CurveXAxisChooser.val == "R0")
            {
                t = Mathf.Clamp01(0.5f + rTarget[0]);
            }
            else if (CurveXAxisChooser.val == "R1")
            {
                t = Mathf.Clamp01(Mathf.Abs(rTarget[1]));
            }
            else if (CurveXAxisChooser.val == "R2")
            {
                t = Mathf.Clamp01(Mathf.Abs(rTarget[2]));
            }
            else if (CurveXAxisChooser.val == "R1+R2")
            {
                t = Mathf.Clamp01(Mathf.Sqrt(rTarget[1] * rTarget[1] + rTarget[2] * rTarget[2]));
            }
            else if (CurveXAxisChooser.val == "L0+R1+R2")
            {
                t = Mathf.Clamp01(Mathf.Sqrt(xTarget[0] * xTarget[0] + rTarget[1] * rTarget[1] + rTarget[2] * rTarget[2]));
            }
            else if (CurveXAxisChooser.val == "Time")
            {
                var timeLimit = TimeSpanSlider.val;
                var time      = TimeScrubberSlider.val;
                if (TineRunningToggle.val)
                {
                    time += Time.deltaTime;
                }

                if (time > timeLimit)
                {
                    time = TimeLoopingToggle.val ? 0 : timeLimit;
                }

                t = Mathf.Clamp(time, 0, timeLimit);
                TimeScrubberSlider.val = t;
            }

            _editor.SetScrubberPosition(_storable, t);
            return(_storable.val.Evaluate(t));
        }