示例#1
0
 private void OnValidate()
 {
     if (Application.isPlaying && m_easeFunc != EasingFunction.GetEasingFunction(m_easeType))
     {
         m_easeFunc = EasingFunction.GetEasingFunction(m_easeType);
     }
 }
    public ComplexMath(List <object> parameters)
    {
        offset   = float.Parse(parameters[0].ToString());
        freq     = float.Parse(parameters[1].ToString());
        startVal = float.Parse(parameters[2].ToString());
        endVal   = float.Parse(parameters[3].ToString());
        int amFuncIndex  = int.Parse(parameters[4].ToString());
        int fmFuncIndex  = int.Parse(parameters[5].ToString());
        var mathFuncType = (MathFunc)int.Parse(parameters[6].ToString());

        mathFunc = linear;
        switch (mathFuncType)
        {
        case MathFunc.Linear:
            mathFunc = linear;
            break;

        case MathFunc.Poly2:
            mathFunc = poly2;
            break;

        case MathFunc.Poly3:
            mathFunc = poly3;
            break;

        case MathFunc.Sine:
            mathFunc = Mathf.Sin;
            break;

        case MathFunc.Exp:
            mathFunc = Mathf.Exp;
            break;

        case MathFunc.Log:
            mathFunc = Mathf.Log;
            break;

        case MathFunc.Sqrt:
            mathFunc = Mathf.Sqrt;
            break;

        case MathFunc.Easing:
            if (parameters.Count > 7)
            {
                int easingIndex = int.Parse(parameters[7].ToString());
                innerEasingStart = parameters.Count > 8? float.Parse(parameters[8].ToString()):0;
                innerEasingEnd   = parameters.Count > 9? float.Parse(parameters[9].ToString()):1;
                easing           = EasingFunction.GetEasingFunction((EasingFunction.Ease)easingIndex);
                mathFunc         = (val) => {
                    return(easing(innerEasingStart, innerEasingEnd, val));
                };
            }
            break;
        }

        amEase = amFuncIndex >= 0? EasingFunction.GetEasingFunction((EasingFunction.Ease)amFuncIndex) : constant;
        fmEase = fmFuncIndex >= 0? EasingFunction.GetEasingFunction((EasingFunction.Ease)fmFuncIndex) : constant;
    }
示例#3
0
        public bool Play(Vector3 _from, Vector3 _to)
        {
            m_From = _from;
            m_To   = _to;

            m_Dir      = (m_To - m_From);
            m_Distance = m_Dir.magnitude;
            m_Dir.Normalize();
            m_CurveEvalDir = new Vector3(-m_Dir.y, m_Dir.x, 0.0f);    // 逆时针旋转90度

            m_ElapsedTime  = 0.0f;
            m_EaseFunction = EasingFunction.GetEasingFunction(EaseType);
            enabled        = true;

            return(true);
        }
示例#4
0
        public static IEnumerator Upper(float value, float goal, float seconds = 1, EasingFunction.Ease easing = EasingFunction.Ease.Linear)
        {
            float orig = value;
            float i    = 0.0f;
            float sT   = Time.time;

            while (i < 1.0f)
            {
                i = (Time.time - sT) / (seconds);

                EasingFunction.Ease     ease = easing;
                EasingFunction.Function func = EasingFunction.GetEasingFunction(ease);

                value = func(orig, goal, i);
                yield return(null);
            }
        }
示例#5
0
        public static IEnumerator Mover(Transform transform, Vector3 newpos, float time, EasingFunction.Ease easing)
        {
            float i  = 0.0f;
            float sT = Time.time;

            while (i < 1.0f)
            {
                i = (Time.time - sT) / (time);

                EasingFunction.Ease     ease = easing;
                EasingFunction.Function func = EasingFunction.GetEasingFunction(ease);

                float x = func(transform.position.x, newpos.x, i);
                float y = func(transform.position.y, newpos.y, i);
                float z = func(transform.position.z, newpos.z, i);

                transform.position = new Vector3(x, y, z);
                yield return(null);
            }
        }
        protected EasingFunction.Function easingFunction; // cached at every execute

        override public void Execute(string eventName)
        {
            if (what == null)
            {
                what = eventSource;
            }

            if (targetRotation == null)
            {
                targetRotation = transform;
            }

            rbToMove       = what.GetComponent <Rigidbody>();
            camRig         = what.GetComponentInChildren <OVRCameraRig>();
            easingFunction = EasingFunction.GetEasingFunction(easing);
            startRotation  = what.transform.rotation;
            endRotation    = targetRotation.rotation;
            if (camRig != null)
            {
                startRigRotation = Quaternion.Euler(OVRManager.instance.headPoseRelativeOffsetRotation);
                Quaternion startCamRotation = camRig.GetComponentInChildren <Camera>().transform.rotation;
                startRotation = camRig.GetComponentInChildren <Camera>().transform.rotation;
                Quaternion diff  = targetRotation.rotation * Quaternion.Inverse(startCamRotation);
                Quaternion diff2 = Quaternion.Inverse(startCamRotation) * targetRotation.rotation;
                endRotation = diff * startRotation;
            }

            // direct test
            OVRManager.instance.headPoseRelativeOffsetRotation = Vector3.zero;
            what.transform.rotation = endRotation;
            //return;

            //startTime = Time.time;

            // Apply immediately

            /*if (duration < 0.00001f)
             * {
             *  ApplyProgress(1);
             * }*/
        }
    // Use this for initialization
    void Start()
    {
        string      text  = skeletonSource.text;
        List <Anim> bones = parseAnim(text, transform);

        for (int i = 0; i < bones.Count; ++i)
        {
            Anim a = bones[i];
            a.transform.localPosition = a.value;
        }


        for (int i = 0; i < framesSource.Length; ++i)
        {
            TextAsset a = framesSource[i];
            frames.Add(parseAnim(a.text, transform));
        }


        easingFunction = EasingFunction.GetEasingFunction(EasingFunction.Ease.EaseInBack);
    }
        protected EasingFunction.Function easingFunction; // cached at every execute

        override public void Execute(string eventName)
        {
            if (what == null)
            {
                what = eventSource;
            }
            if (targetPosition == null)
            {
                targetPosition = transform;
            }

            rbToMove       = what.GetComponent <Rigidbody>();
            startTime      = Time.time;
            startPosition  = what.transform.position;
            easingFunction = EasingFunction.GetEasingFunction(easing);

            // Apply immediately
            if (duration < 0.00001f)
            {
                ApplyProgress(1);
            }
        }
示例#9
0
 /// <summary>
 /// Caches the RectTransform and easing function for later use.
 /// </summary>
 private void Awake()
 {
     rectTransform  = GetComponent <RectTransform>();
     easingFunction = EasingFunction.GetEasingFunction(EaseSettings.EasingFunction);
 }
示例#10
0
 void Start()
 {
     _func           = EasingFunction.GetEasingFunction(colorsEase);
     _targetRenderer = gameObject.GetComponent <MeshRenderer>();
 }
示例#11
0
 /// <summary>
 /// Cache the target image and easing function for use later.
 /// </summary>
 private void Awake()
 {
     image          = (TargetImage == null) ? GetComponent <Image>() : TargetImage;
     easingFunction = EasingFunction.GetEasingFunction(EaseSettings.EasingFunction);
 }
示例#12
0
 private void OnEnable()
 {
     ease       = EasingFunction.GetEasingFunction(EaseFunc);
     easeInTime = -EaseInDelay;
 }
示例#13
0
 private void Awake()
 {
     m_easeFunc = EasingFunction.GetEasingFunction(m_easeType);
 }
示例#14
0
 private void Start()
 {
     _easeFunc = EasingFunction.GetEasingFunction(ease);
 }