Exemple #1
0
 void EmitHOTweenScaleFor(Transform t, Vector3 to, float twDuration, Holoville.HOTween.EaseType ease)
 {
     t.localScale = Vector3.one;
     HOTween.To(t, twDuration, new Holoville.HOTween.TweenParms()
                .Prop("localScale", to)
                .Ease(ease)
                .OnComplete(() => EmitHOTweenScaleFor(t, to, twDuration, ease))
                );
 }
Exemple #2
0
 void EmitHOTweenRotationFor(Transform t, Vector3 to, float twDuration, Holoville.HOTween.EaseType ease)
 {
     t.rotation = Quaternion.identity;
     HOTween.To(t, twDuration, new Holoville.HOTween.TweenParms()
                .Prop("rotation", to)
                .Ease(ease)
                .OnComplete(() => EmitHOTweenRotationFor(t, to, twDuration, ease))
                );
 }
Exemple #3
0
 void EmitHOTweenPositionFor(Transform t, Vector3 to, float twDuration, Holoville.HOTween.EaseType ease)
 {
     t.position = Vector3.zero;
     HOTween.To(t, twDuration, new Holoville.HOTween.TweenParms()
                .Prop("position", to)
                .Ease(ease)
                .OnComplete(() => EmitHOTweenPositionFor(t, to, twDuration, ease))
                );
 }
Exemple #4
0
    void SetupTweens()
    {
        // Ease
        DG.Tweening.Ease           dotweenEase = easing == Easing.Linear ? DG.Tweening.Ease.Linear : DG.Tweening.Ease.InOutQuad;
        Holoville.HOTween.EaseType hotweenEase = easing == Easing.Linear ? Holoville.HOTween.EaseType.Linear : Holoville.HOTween.EaseType.EaseInOutQuad;
        LeanTweenType leanEase = easing == Easing.Linear ? LeanTweenType.linear : LeanTweenType.easeInOutQuad;
        GoEaseType    goEase   = easing == Easing.Linear ? GoEaseType.Linear : GoEaseType.QuadInOut;

        iTween.EaseType iTweenEase = easing == Easing.Linear ? iTween.EaseType.linear : iTween.EaseType.easeInOutQuad;
        // Loop
        int loops = testSetup == TestSetup.Emit ? 1 : -1;

        DG.Tweening.LoopType       dotweenLoopType = testSetup == TestSetup.YoyoLoop ? DG.Tweening.LoopType.Yoyo : DG.Tweening.LoopType.Restart;
        Holoville.HOTween.LoopType hotweenLoopType = testSetup == TestSetup.YoyoLoop ? Holoville.HOTween.LoopType.Yoyo : Holoville.HOTween.LoopType.Restart;
        LeanTweenType leanLoopType = testSetup == TestSetup.YoyoLoop ? LeanTweenType.pingPong : LeanTweenType.clamp;
        GoLoopType    goLoopType   = testSetup == TestSetup.YoyoLoop ? GoLoopType.PingPong : GoLoopType.RestartFromBeginning;

        iTween.LoopType iTweenLoopType = loops != -1 ? iTween.LoopType.none : testSetup == TestSetup.YoyoLoop ? iTween.LoopType.pingPong : iTween.LoopType.loop;
        // Create tweens
        switch (testType)
        {
        case TestType.Floats:
            for (int i = 0; i < numTweens; ++i)
            {
                TestObjectData data = testObjsData[i];
                switch (engine)
                {
                case Engine.HOTween:
                    HOTween.To(data, duration, new Holoville.HOTween.TweenParms()
                               .Prop("floatValue", rndFloats[i])
                               .Ease(hotweenEase)
                               .Loops(loops, hotweenLoopType)
                               );
                    break;

                case Engine.LeanTween:
                    LeanTween.value(this.gameObject, x => data.floatValue = x, data.floatValue, rndFloats[i], duration).setEase(leanEase).setRepeat(loops).setLoopType(leanLoopType);
                    break;

                case Engine.GoKit:
                    Go.to(data, duration, new GoTweenConfig()
                          .floatProp("floatValueProperty", rndFloats[i])
                          .setEaseType(goEase)
                          .setIterations(loops, goLoopType)
                          );
                    break;

                case Engine.iTween:
                    Hashtable hs = new Hashtable();
                    hs.Add("from", data.floatValue);
                    hs.Add("to", rndFloats[i]);
                    hs.Add("time", duration);
                    hs.Add("onupdate", "UpdateiTweenFloat");
                    hs.Add("looptype", iTweenLoopType);
                    hs.Add("easetype", iTweenEase);
                    iTween.ValueTo(this.gameObject, hs);
                    break;

                default:
                    // tCopy is needed to create correct closure object,
                    // otherwise closure will pass the same t to all the loop
                    TestObjectData dataCopy = data;
                    DOTween.To(() => dataCopy.floatValue, x => dataCopy.floatValue = x, rndFloats[i], duration).SetEase(dotweenEase).SetLoops(loops, dotweenLoopType);
                    break;
                }
            }
            break;

        default:
            for (int i = 0; i < numTweens; ++i)
            {
                float      twDuration = testSetup == TestSetup.Emit ? UnityEngine.Random.Range(0.25f, 1f) : duration;
                Transform  t          = testObjsTrans[i];
                GameObject go         = testObjsGos[i];         // Used by LeanTween and iTween
                switch (engine)
                {
                case Engine.HOTween:
                    Holoville.HOTween.TweenParms tp = new Holoville.HOTween.TweenParms()
                                                      .Ease(hotweenEase)
                                                      .Loops(loops, hotweenLoopType);
                    if (positionTween)
                    {
                        Vector3 toPos = rndPositions[i];
                        tp.Prop("position", toPos);
                        if (testSetup == TestSetup.Emit)
                        {
                            tp.OnComplete(() => EmitHOTweenPositionFor(t, toPos, twDuration, hotweenEase));
                        }
                    }
                    if (rotationTween)
                    {
                        Vector3 toRot = rndRotations[i];
                        tp.Prop("rotation", toRot);
                        if (testSetup == TestSetup.Emit)
                        {
                            tp.OnComplete(() => EmitHOTweenRotationFor(t, toRot, twDuration, hotweenEase));
                        }
                    }
                    if (scaleTween)
                    {
                        tp.Prop("localScale", rndScale);
                        if (testSetup == TestSetup.Emit)
                        {
                            tp.OnComplete(() => EmitHOTweenScaleFor(t, rndScale, twDuration, hotweenEase));
                        }
                    }
                    HOTween.To(t, twDuration, tp);
                    break;

                case Engine.LeanTween:
                    LTDescr leanTween;
                    if (positionTween)
                    {
                        Vector3 toPos = rndPositions[i];
                        leanTween = LeanTween.move(go, rndPositions[i], twDuration).setEase(leanEase).setRepeat(loops).setLoopType(leanLoopType);
                        if (testSetup == TestSetup.Emit)
                        {
                            leanTween.setOnComplete(() => EmitLeanTweenPositionFor(t, go, toPos, twDuration, leanEase));
                        }
                    }
                    if (rotationTween)
                    {
                        Vector3 toRot = rndRotations[i];
                        leanTween = LeanTween.rotate(go, rndRotations[i], twDuration).setEase(leanEase).setRepeat(loops).setLoopType(leanLoopType);
                        if (testSetup == TestSetup.Emit)
                        {
                            leanTween.setOnComplete(() => EmitLeanTweenRotationFor(t, go, toRot, twDuration, leanEase));
                        }
                    }
                    if (scaleTween)
                    {
                        leanTween = LeanTween.scale(go, rndScale, twDuration).setEase(leanEase).setRepeat(loops).setLoopType(leanLoopType);
                        if (testSetup == TestSetup.Emit)
                        {
                            leanTween.setOnComplete(() => EmitLeanTweenScaleFor(t, go, rndScale, twDuration, leanEase));
                        }
                    }
                    break;

                case Engine.GoKit:
                    GoTweenConfig goConfig = new GoTweenConfig()
                                             .setEaseType(goEase)
                                             .setIterations(loops, goLoopType);
                    if (positionTween)
                    {
                        Vector3 toPos = rndPositions[i];
                        goConfig.addTweenProperty(new PositionTweenProperty(toPos));
                        if (testSetup == TestSetup.Emit)
                        {
                            goConfig.onComplete(x => EmitGoKitPositionFor(t, toPos, twDuration, goEase));
                        }
                    }
                    if (rotationTween)
                    {
                        Vector3 toRot = rndRotations[i];
                        goConfig.addTweenProperty(new RotationTweenProperty(toRot));
                        if (testSetup == TestSetup.Emit)
                        {
                            goConfig.onComplete(x => EmitGoKitRotationFor(t, toRot, twDuration, goEase));
                        }
                    }
                    if (scaleTween)
                    {
                        goConfig.addTweenProperty(new ScaleTweenProperty(rndScale));
                        if (testSetup == TestSetup.Emit)
                        {
                            goConfig.onComplete(x => EmitGoKitScaleFor(t, rndScale, twDuration, goEase));
                        }
                    }
                    Go.to(t, twDuration, goConfig);
                    break;

                case Engine.iTween:
                    Hashtable hs;
                    if (positionTween)
                    {
                        hs = new Hashtable();
                        hs.Add("position", rndPositions[i]);
                        hs.Add("time", twDuration);
                        hs.Add("looptype", iTweenLoopType);
                        hs.Add("easetype", iTweenEase);
                        iTween.MoveTo(go, hs);
                    }
                    if (rotationTween)
                    {
                        hs = new Hashtable();
                        hs.Add("rotation", rndRotations[i]);
                        hs.Add("time", twDuration);
                        hs.Add("looptype", iTweenLoopType);
                        hs.Add("easetype", iTweenEase);
                        iTween.RotateTo(go, hs);
                    }
                    if (scaleTween)
                    {
                        hs = new Hashtable();
                        hs.Add("scale", rndScale);
                        hs.Add("time", twDuration);
                        hs.Add("looptype", iTweenLoopType);
                        hs.Add("easetype", iTweenEase);
                        iTween.ScaleTo(go, hs);
                    }
                    break;

                default:
                    // tCopy is needed to create correct closure object,
                    // otherwise closure will pass the same t to all the loop
                    Transform         tCopy = t;
                    DG.Tweening.Tween dotween;
                    if (positionTween)
                    {
                        Vector3 toPos = rndPositions[i];
                        dotween = tCopy.DOMove(toPos, twDuration).SetEase(dotweenEase).SetLoops(loops, dotweenLoopType);
                        if (testSetup == TestSetup.Emit)
                        {
                            dotween.OnComplete(() => EmitDOTweenPositionFor(t, toPos, twDuration, dotweenEase));
                        }
                    }
                    if (rotationTween)
                    {
                        Vector3 toRot = rndRotations[i];
                        dotween = tCopy.DORotate(toRot, twDuration).SetEase(dotweenEase).SetLoops(loops, dotweenLoopType);
                        if (testSetup == TestSetup.Emit)
                        {
                            dotween.OnComplete(() => EmitDOTweenRotationFor(t, toRot, twDuration, dotweenEase));
                        }
                    }
                    if (scaleTween)
                    {
                        dotween = tCopy.DOScale(rndScale, twDuration).SetEase(dotweenEase).SetLoops(loops, dotweenLoopType);
                        if (testSetup == TestSetup.Emit)
                        {
                            dotween.OnComplete(() => EmitDOTweenScaleFor(t, rndScale, twDuration, dotweenEase));
                        }
                    }
                    break;
                }
            }
            break;
        }
    }
Exemple #5
0
    public static Holoville.HOTween.EaseType EaseTypeConvert(eEaseType easeType)
    {
        Holoville.HOTween.EaseType result = Holoville.HOTween.EaseType.Linear;
        switch (easeType)
        {
        case eEaseType.InQuad: result = Holoville.HOTween.EaseType.EaseInQuad; break;

        case eEaseType.OutQuad:        result = Holoville.HOTween.EaseType.EaseOutQuad; break;

        case eEaseType.InOutQuad:      result = Holoville.HOTween.EaseType.EaseInOutQuad; break;

        case eEaseType.InCubic:        result = Holoville.HOTween.EaseType.EaseOutCubic; break;

        case eEaseType.OutCubic:       result = Holoville.HOTween.EaseType.EaseOutCubic; break;

        case eEaseType.InOutCubic:     result = Holoville.HOTween.EaseType.EaseInOutCubic; break;

        case eEaseType.InQuart:        result = Holoville.HOTween.EaseType.EaseInQuart; break;

        case eEaseType.OutQuart:       result = Holoville.HOTween.EaseType.EaseOutQuart; break;

        case eEaseType.InOutQuart:     result = Holoville.HOTween.EaseType.EaseInOutQuart; break;

        case eEaseType.InQuint:        result = Holoville.HOTween.EaseType.EaseInQuint; break;

        case eEaseType.OutQuint:       result = Holoville.HOTween.EaseType.EaseOutQuint; break;

        case eEaseType.InOutQuint:     result = Holoville.HOTween.EaseType.EaseInOutQuint; break;

        case eEaseType.InSine: result = Holoville.HOTween.EaseType.EaseInSine; break;

        case eEaseType.OutSine:        result = Holoville.HOTween.EaseType.EaseOutSine; break;

        case eEaseType.InOutSine:      result = Holoville.HOTween.EaseType.EaseInOutSine; break;

        case eEaseType.InExpo: result = Holoville.HOTween.EaseType.EaseInExpo; break;

        case eEaseType.OutExpo:        result = Holoville.HOTween.EaseType.EaseOutExpo; break;

        case eEaseType.InOutExpo:      result = Holoville.HOTween.EaseType.EaseInOutExpo; break;

        case eEaseType.InCirc: result = Holoville.HOTween.EaseType.EaseInCirc; break;

        case eEaseType.OutCirc:        result = Holoville.HOTween.EaseType.EaseOutCirc; break;

        case eEaseType.InOutCirc:      result = Holoville.HOTween.EaseType.EaseInOutCirc; break;

        case eEaseType.linear: result = Holoville.HOTween.EaseType.Linear; break;

        case eEaseType.InBounce:       result = Holoville.HOTween.EaseType.EaseInBounce; break;

        case eEaseType.OutBounce:      result = Holoville.HOTween.EaseType.EaseOutBounce; break;

        case eEaseType.InOutBounce:    result = Holoville.HOTween.EaseType.EaseInOutBounce; break;

        case eEaseType.InBack: result = Holoville.HOTween.EaseType.EaseInBack; break;

        case eEaseType.OutBack:        result = Holoville.HOTween.EaseType.EaseOutBack; break;

        case eEaseType.InOutBack:      result = Holoville.HOTween.EaseType.EaseInOutBack; break;

        case eEaseType.InElastic:      result = Holoville.HOTween.EaseType.EaseInElastic; break;

        case eEaseType.OutElastic:     result = Holoville.HOTween.EaseType.EaseOutElastic; break;

        case eEaseType.InOutElastic:   result = Holoville.HOTween.EaseType.EaseInOutElastic; break;

        default:       result = Holoville.HOTween.EaseType.Linear; break;
        }
        return(result);
    }