示例#1
0
    private TweenAction AddTween(Transform obj, Vector3 target, TweenAction.Type type, float duration, float delay, System.Func <float, float> ease, int easeIndex = -1, bool removeOld = true)
    {
        // remove old ones of same object
        if (removeOld)
        {
            for (int i = actions.Count - 1; i >= 0; i--)
            {
                if (actions[i].theObject == obj && actions[i].type == type)
                {
                    actions.RemoveAt(i);
                }
            }
        }

        TweenAction act = new TweenAction
        {
            type          = type,
            theObject     = obj,
            targetPos     = target,
            tweenPos      = 0f,
            tweenDuration = duration,
            tweenDelay    = delay,
            customEasing  = easeIndex
        };

        actions.Add(act);

        act.easeFunction = ease;

        return(act);
    }
示例#2
0
    public Guid AddTween(
        object target,
        float duration,
        float startValue,
        float endValue,
        TweenerTickAction <object> onTickAction,
        ITweenEffect effect = null,
        TwennerOnCompleted <object> onCompleteAction = null,
        object onCompleteParam = null,
        TweenTimeMode timeMode = TweenTimeMode.Normal)
    {
        var newAction = new TweenAction
        {
            Id              = Guid.NewGuid(),
            Target          = target,
            Duration        = duration,
            StartValue      = startValue,
            EndValue        = endValue,
            ChangeValue     = endValue - startValue,
            OnTick          = onTickAction,
            Effect          = effect ?? TweenEffectsFactory.LinearEffect,
            OnComplete      = onCompleteAction,
            OnCompleteParam = onCompleteParam,
            Mode            = timeMode,
            StartTime       = (timeMode == TweenTimeMode.Normal) ? Time.time : Time.unscaledTime,
        };

        _actions.Add(newAction);
        return(newAction.Id);
    }
示例#3
0
 public static TweenOperation Prepare(TObject target,PropertyAccesser<TObject,TValue> property, TValue from,TweenOptions options){
     var state = new State(){
         from = from,
         target = target,
         property = property
     };
     return TweenAction<State>.Prepare(state,options);          
 }
示例#4
0
    public void ScaleTo(Transform obj, Vector3 target, float duration, float delay, System.Func <float, float> ease = null, int easeIndex = -1, bool removeOld = true)
    {
        if (ease == null)
        {
            ease = TweenEasings.LinearInterpolation;
        }

        TweenAction act = AddTween(obj, target, TweenAction.Type.Scale, duration, delay, ease, easeIndex, removeOld);

        StartCoroutine(act.SetStartScale());
    }
示例#5
0
    public void MoveLocalTo(Transform obj, Vector3 target, float duration, float delay, System.Func <float, float> ease = null, int easeIndex = -1)
    {
        if (ease == null)
        {
            ease = TweenEasings.LinearInterpolation;
        }

        TweenAction act = AddTween(obj, target, TweenAction.Type.LocalPosition, duration, delay, ease, easeIndex);

        act.startPos = act.theObject.localPosition;
    }
示例#6
0
    public void MoveTo(Transform obj, Vector3 target, float duration, float delay, System.Func <float, float> ease = null, int easeIndex = -1, bool removeOld = true)
    {
        if (ease == null)
        {
            ease = TweenEasings.LinearInterpolation;
        }

        TweenAction act = AddTween(obj, target, TweenAction.Type.Position, duration, delay, ease, easeIndex, removeOld);

        act.startPos = act.theObject.position;
    }
示例#7
0
            public static TweenOperation Prepare(object target, IPropertyAccesser <TValue> property, TValue to, TweenOptions options)
            {
                var state = new State()
                {
                    to       = to,
                    target   = target,
                    property = property
                };

                return(TweenAction <State> .Prepare(state, options));
            }
示例#8
0
    public void RotateTo(Transform obj, Quaternion rotation, float duration, float delay, System.Func <float, float> ease = null, int easeIndex = -1)
    {
        if (ease == null)
        {
            ease = TweenEasings.LinearInterpolation;
        }

        TweenAction act = AddTween(obj, Vector3.zero, TweenAction.Type.Rotation, duration, delay, ease, easeIndex);

        act.startRot  = act.theObject.rotation;
        act.targetRot = rotation;
    }
示例#9
0
            public static TweenOperation Prepare(TValue from, TValue to, InterpolationUpdate <TValue, TContext> onUpdate, TContext context, TweenOptions options)
            {
                var state = new State()
                {
                    from     = from,
                    to       = to,
                    onUpdate = onUpdate,
                    context  = context,
                };

                return(TweenAction <State> .Prepare(state, options));
            }
示例#10
0
文件: Tweener.cs 项目: Dacow1707/fff
    public void MoveBodyTo(Rigidbody2D obj, Vector3 target, float duration, float delay, System.Func <float, float> ease = null, int easeIndex = -1, bool removeOld = true)
    {
        if (ease == null)
        {
            ease = TweenEasings.LinearInterpolation;
        }

        TweenAction act = AddTween(obj, target, TweenAction.Type.BodyPosition, duration, delay, ease, easeIndex, removeOld);

        act.startPos = act.body.position;
        StartCoroutine(act.SetBodyStartPos());
    }
示例#11
0
文件: Tweener.cs 项目: Dacow1707/fff
    public void RotateBodyTo(Rigidbody2D obj, Quaternion rotation, float duration, float delay, System.Func <float, float> ease = null, int easeIndex = -1, bool removeOld = true)
    {
        if (ease == null)
        {
            ease = TweenEasings.LinearInterpolation;
        }

        TweenAction act = AddTween(obj, Vector3.zero, TweenAction.Type.BodyRotation, duration, delay, ease, easeIndex, removeOld);

        act.startRot  = act.body.transform.rotation;
        act.targetRot = rotation;
        StartCoroutine(act.SetBodyStartRot());
    }
示例#12
0
 // Instantiates LeanTweenGroup by making a copy of group.
 // <param name="group">Group.</param>
 public LeanTweenItem(LeanTweenItem item)
 {
     name     = item.name;
     action   = item.action;
     between  = item.between;
     ease     = item.ease;
     from     = item.from;
     to       = item.to;
     axis     = item.axis;
     duration = item.duration;
     delay    = item.delay;
     foldout  = item.foldout;
 }
示例#13
0
    public void ColorTo(SpriteRenderer obj, Color color, float duration, float delay, System.Func <float, float> ease = null, int easeIndex = -1)
    {
        if (ease == null)
        {
            ease = TweenEasings.LinearInterpolation;
        }

        TweenAction act = AddTween(obj.transform, Vector3.zero, TweenAction.Type.Color, duration, delay, ease, easeIndex);

        act.sprite      = obj;
        act.startColor  = act.sprite.color;
        act.targetColor = color;
    }
示例#14
0
文件: Tweener.cs 项目: Dacow1707/fff
    public void ColorTo(Image obj, Color color, float duration, float delay, System.Func <float, float> ease = null, int easeIndex = -1, bool removeOld = true)
    {
        if (ease == null)
        {
            ease = TweenEasings.LinearInterpolation;
        }

        TweenAction act = AddTween(obj.transform, Vector3.zero, TweenAction.Type.Color, duration, delay, ease, easeIndex, removeOld);

        act.uiImage     = obj;
        act.startColor  = act.uiImage.color;
        act.targetColor = color;
        StartCoroutine(act.SetStartColor());
    }
示例#15
0
 // Instantiates LeanTweenGroup by making a copy of group.
 // <param name="group">Group.</param>
 public LeanTweenItem(LeanTweenItem item)
 {
     itemName  = item.itemName;
     action    = item.action;
     recursive = item.recursive;
     between   = item.between;
     ease      = item.ease;
     from      = item.from;
     to        = item.to;
     axis      = item.axis;
     duration  = item.duration;
     delay     = item.delay;
     loopDelay = item.loopDelay;
     foldout   = item.foldout;
 }
示例#16
0
 public void SelectMoveToTween()
 {
     SelectedTweenAction = new MoveToTweenAction();
 }
示例#17
0
 public LTDescr setMove()
 {
     this.type = TweenAction.MOVE;
     this.initInternal = ()=>{ this.from = trans.position; };
     this.easeInternal = ()=>{
         newVect = easeMethod();
         trans.position = newVect;
     };
     return this;
 }
示例#18
0
 public LTDescr setCanvasSizeDelta()
 {
     this.type = TweenAction.CANVAS_SIZEDELTA;
     this.initInternal = ()=>{ this.from = this.rectTransform.sizeDelta; };
     this.easeInternal = ()=>{ this.rectTransform.sizeDelta = easeMethod(); };
     return this;
 }
示例#19
0
    public LTDescr setAlpha()
    {
        this.type = TweenAction.ALPHA;
        this.initInternal = ()=>{
            #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
            if(trans.gameObject.renderer){ this.fromInternal.x = trans.gameObject.renderer.material.color.a; }else if(trans.childCount>0){ foreach (Transform child in trans) { if(child.gameObject.renderer!=null){ Color col = child.gameObject.renderer.material.color; this.fromInternal.x = col.a; break; }}}
            this.easeInternal = this.alpha;
            break;
            #else
            SpriteRenderer ren = trans.gameObject.GetComponent<SpriteRenderer>();
            if(ren!=null){
                this.fromInternal.x = ren.color.a;
            }else{
                if(trans.gameObject.GetComponent<Renderer>()!=null && trans.gameObject.GetComponent<Renderer>().material.HasProperty("_Color")){
                    this.fromInternal.x = trans.gameObject.GetComponent<Renderer>().material.color.a;
                }else if(trans.gameObject.GetComponent<Renderer>()!=null && trans.gameObject.GetComponent<Renderer>().material.HasProperty("_TintColor")){
                    Color col = trans.gameObject.GetComponent<Renderer>().material.GetColor("_TintColor");
                    this.fromInternal.x = col.a;
                }else if(trans.childCount>0){
                    foreach (Transform child in trans) {
                        if(child.gameObject.GetComponent<Renderer>()!=null){
                            Color col = child.gameObject.GetComponent<Renderer>().material.color;
                            this.fromInternal.x = col.a;
                            break;
                        }
                    }
                }
            }
            #endif

            this.easeInternal = ()=>{
                val = easeMethod().x;
                #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
                alphaRecursive(this.trans, val, this.useRecursion);
                #else
                if(this.spriteRen!=null){
                    this.spriteRen.color = new Color( this.spriteRen.color.r, this.spriteRen.color.g, this.spriteRen.color.b, val);
                    alphaRecursiveSprite(this.trans, val);
                }else{
                    alphaRecursive(this.trans, val, this.useRecursion);
                }
                #endif
            };

        };
        this.easeInternal = ()=>{
            newVect = easeMethod();
            val = newVect.x;
            #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
            alphaRecursive(this.trans, val, this.useRecursion);
            #else
            if(this.spriteRen!=null){
                this.spriteRen.color = new Color( this.spriteRen.color.r, this.spriteRen.color.g, this.spriteRen.color.b, val);
                alphaRecursiveSprite(this.trans, val);
            }else{
                alphaRecursive(this.trans, val, this.useRecursion);
            }
            #endif
        };
        return this;
    }
示例#20
0
 public LTDescr setCanvasMoveZ()
 {
     this.type = TweenAction.CANVAS_MOVE_Z;
     this.initInternal = ()=>{ this.fromInternal.x = this.rectTransform.anchoredPosition3D.z; };
     this.easeInternal = ()=>{ Vector3 c = this.rectTransform.anchoredPosition3D; this.rectTransform.anchoredPosition3D = new Vector3(c.x, c.y, easeMethod().x); };
     return this;
 }
示例#21
0
    public LTDescr setCanvasRotateAroundLocal()
    {
        this.type = TweenAction.CANVAS_ROTATEAROUND_LOCAL;
        this.initInternal = this.initCanvasRotateAround;
        this.easeInternal = ()=>{
            newVect = easeMethod();
            val = newVect.x;
            RectTransform rect = this.rectTransform;
            Vector3 origPos = rect.localPosition;
            rect.RotateAround((Vector3)rect.TransformPoint( this._optional.point ), rect.TransformDirection(this._optional.axis), -val);
            Vector3 diff = origPos - rect.localPosition;

            rect.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position
            rect.rotation = this._optional.origRotation;
            rect.RotateAround((Vector3)rect.TransformPoint( this._optional.point ), rect.TransformDirection(this._optional.axis), val);
        };
        return this;
    }
示例#22
0
 public void SelectValueTween()
 {
     SelectedTweenAction = new ValueTweenAction();
 }
示例#23
0
 public LTDescr setCanvasGroupAlpha()
 {
     this.type = TweenAction.CANVASGROUP_ALPHA;
     this.initInternal = ()=>{this.fromInternal.x = trans.gameObject.GetComponent<CanvasGroup>().alpha;};
     this.easeInternal = ()=>{ this.trans.GetComponent<CanvasGroup>().alpha = easeMethod().x; };
     return this;
 }
示例#24
0
 public void SelectColorFlashTween()
 {
     SelectedTweenAction = new ColorFlashTweenAction();
 }
示例#25
0
 public void SelectJump2DTween()
 {
     SelectedTweenAction = new Jump2DTweenAction();
 }
示例#26
0
            static PropertyController()
            {
                TweenAction <State> .RegisterStart(OnStart);

                TweenAction <State> .RegisterUpdate(OnUpdate);
            }
示例#27
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            LeanTweenVisual mainTarget = target as LeanTweenVisual;

            EditorGUI.BeginChangeCheck();
            float   overallDelay = 0;
            bool    clicked, deleted;
            Vector3 vec;

            clicked = false;

            bool playOnStartBefore = mainTarget.playOnStart;

            EditorGUILayout.BeginHorizontal();
            bool playOnStartNow = EditorGUILayout.Toggle(new GUIContent("Play on Start", "Tweens won't start automatically, you can start them via code with .start()"), mainTarget.playOnStart);


            EditorGUILayout.EndHorizontal();

            if (playOnStartBefore != playOnStartNow)
            {
                foreach (LeanTweenVisual tweenVisual in tweens)
                {
                    Undo.RecordObject(tweenVisual, "Toggling play on start");
                    tweenVisual.playOnStart = playOnStartNow;
                }
            }

            EditorGUILayout.BeginHorizontal();
            bool generateCode = EditorGUILayout.Toggle(new GUIContent("Generate Code", "If C# code will be generated"), mainTarget.generateCode);

            tweens.ForEach(tween => tween.generateCode = generateCode);

            GUIContent restartOnEnableGui      = new GUIContent("Restart on enable", "When you enable the gameobject these set of tweens will start again");
            bool       newRestartOnEnableValue = EditorGUILayout.Toggle(restartOnEnableGui, mainTarget.restartOnEnable);

            foreach (LeanTweenVisual leanTween in tweens)
            {
                Change(ref leanTween.restartOnEnable, newRestartOnEnableValue, leanTween, "Restart on Enable");
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();

            #region Simulation Stuff

            if (mainTarget.isSimulating)
            {
                GUI.enabled = false;
            }

            EditorGUILayout.BeginHorizontal();
            bool simulateTemp = EditorGUILayout.Toggle(new GUIContent("Simulate", "Mark to see the tweens in the edit mode."), mainTarget.simulate);
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;

            // Reset Values
            EditorGUILayout.BeginHorizontal();
            if (!mainTarget.isSimulating)
            {
                GUI.enabled = false;
            }
            bool stopSimulation = EditorGUILayout.Toggle(new GUIContent("Stop simulation", "Click to stop the simulation"), mainTarget.stopSimulation);
            GUI.enabled = true;
            foreach (LeanTweenVisual visual in tweens)
            {
                if (visual.isSimulating)
                {
                    visual.stopSimulation = stopSimulation;
                }
            }

            if (mainTarget.isSimulating)
            {
                GUI.enabled = false;
            }
            bool resetValues = EditorGUILayout.Toggle(new GUIContent("Reset Values", "Click when the values of your GameObject don't reset after simulation."),
                                                      mainTarget.resetValues);
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();

            for (int i = 0; i < tweens.Length; i++)
            {
                if (!tweens[i].isSimulating)
                {
                    if (resetValues && tweens[i].hasSimulated)
                    {
                        ResetValues(tweens[i]);
                    }
                }
                else
                {
                    if (stopSimulation)
                    {
                        tweens[i].Cancel();
                        StopSimulation(tweens[i]);
                    }
                }
            }

            for (int i = 0; i < tweens.Length; i++)
            {
                if (!tweens[i].isSimulating)
                {
                    tweens[i].simulate = simulateTemp;
                    if (simulateTemp)
                    {
                        tweens[i].isSimulating = true;

                        GetStartValues(tweens[i]);
                        tweens[i].simulationTimer = tweens[i].GetAllGroupsTotalDuration() + Time.realtimeSinceStartup + tweens[i].timeToFinishSimulation;
                        if (qttOfAtualSimulations == 0)
                        {
                            EditorApplication.update += () => SimulationTimer(tweens);
                        }

                        if (tweens[i].loopAllCount < 0)
                        {
                            tweens[i].resetRepeatAfterSimulation = true;
                            tweens[i].loopAllCount = tweens[i].defaultLoopCount;
                        }
                        LeanTween.canUseInEditMode = true;
                        tweens[i].Simulate();

                        tweens[i].simulate = false;
                    }
                }
            }

            EditorGUILayout.BeginHorizontal();
            Change(ref mainTarget.timeToFinishSimulation,
                   EditorGUILayout.FloatField(new GUIContent("Time To Finish", "Time until restart this GameObject when simulate finishes."), mainTarget.timeToFinishSimulation),
                   mainTarget,
                   "Time to Finish");
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUIContent defaultLoopGui = new GUIContent("Default Loop Count",
                                                       "Default loop count in a simulation when loopCount is infinite. (In Play Mode will work normally)");

            Change(ref mainTarget.defaultLoopCount,
                   EditorGUILayout.IntField(defaultLoopGui, mainTarget.defaultLoopCount),
                   mainTarget,
                   "Default loop count");

            if (mainTarget.defaultLoopCount < 2)
            {
                mainTarget.defaultLoopCount = 2;
            }

            EditorGUILayout.EndHorizontal();

            #endregion

            EditorGUILayout.Separator();

            #region Repeat Stuff

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField(new GUIContent("All Delay", "Delay before start the whole set of tween groups."), GUILayout.Width(90));
            float newAllDelay = EditorGUILayout.FloatField("", mainTarget.allDelay);
            for (int i = 0; i < tweens.Length; i++)
            {
                Change(ref tweens[i].allDelay, newAllDelay, tweens[i], "All delay");
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            bool newDoesAllLoop = EditorGUILayout.Toggle(new GUIContent("Loop All", "Repeat the whole set of tween groups once they finish"), mainTarget.doesAllLoop);
            for (int i = 0; i < tweens.Length; i++)
            {
                Change(ref tweens[i].doesAllLoop, newDoesAllLoop, tweens[i], "Loop All");
            }
            EditorGUILayout.EndHorizontal();

            if (mainTarget.doesAllLoop)
            {
                float newLoopAllDelay = EditorGUILayout.FloatField(new GUIContent("    Loop All Delay", "Delay between each all loop."), mainTarget.loopAllDelay);
                for (int i = 0; i < tweens.Length; i++)
                {
                    Change(ref tweens[i].loopAllDelay, newLoopAllDelay, tweens[i], "Loop All Delay");
                }

                int newLoopAllCount = EditorGUILayout.IntField(new GUIContent("    Loop All Count", "Quantity of loops all tweens will make."), mainTarget.loopAllCount);
                for (int i = 0; i < tweens.Length; i++)
                {
                    Change(ref tweens[i].loopAllCount, newLoopAllCount, tweens[i], "Loop All Count");
                }

                if (mainTarget.loopAllCount == 0 || mainTarget.loopAllCount == 1)
                {
                    tweens.ForEach(x => x.loopAllCount = 2);
                }
            }
            #endregion


            float addedGroupDelay = 0f;
            int   groupIndex      = 0;
            foreach (LeanTweenGroup group in mainTarget.groupList)
            {
                EditorGUILayout.Space();

                EditorGUILayout.BeginHorizontal();
                GUI.color = LTEditor.Shared.colorGroupName;

                group.foldout = EditorGUILayout.Foldout(group.foldout, "", LTEditor.Shared.styleGroupFoldout);

                string groupStatus = "Group: " + group.groupName + " " + (group.StartTime) + "s - " + (mainTarget.GetGroupEndTime(group) + group.StartTime) + "s";
                if (group.doesLoop)
                {
                    if (group.loopCount < 1)
                    {
                        groupStatus += "    (* %%)";
                    }
                    else
                    {
                        groupStatus += "    (* " + group.loopCount + ")";
                    }
                }

                clicked   = GUILayout.Button(groupStatus, LTEditor.Shared.styleGroupButton);
                GUI.color = LTEditor.Shared.colorDelete;
                deleted   = GUILayout.Button("Delete", LTEditor.Shared.styleDeleteGroupButton);
                EditorGUILayout.EndHorizontal();
                GUI.color = Color.white;

                if (clicked)
                {
                    group.foldout = !group.foldout;
                }
                if (deleted)
                {
                    Undo.RecordObject(mainTarget, "Removing group item");
                    mainTarget.groupList.Remove(group);
                    break;
                }

                float addedTweenDelay = 0f;
                if (group.foldout)
                {
                    group.groupName = EditorGUILayout.TextField("Group Name", group.groupName);
                    EditorGUILayout.BeginHorizontal();
                    group.doesLoop = EditorGUILayout.Toggle("Group Loop", group.doesLoop);
                    group.delay    = EditorGUILayout.FloatField("Group Delay", group.delay);
                    EditorGUILayout.EndHorizontal();

                    if (group.doesLoop)
                    {
                        group.loopCount = EditorGUILayout.IntField("Group Loop Count", group.loopCount);
                        if (group.loopCount == 0 || group.loopCount == 1)
                        {
                            group.loopCount = 2;
                        }

                        group.loopDelay = EditorGUILayout.FloatField(new GUIContent("Group Loop Delay", "Delay between each group loop"), group.loopDelay);
                    }

                    group.gameObject = EditorGUILayout.ObjectField("Group GameObject", group.gameObject, typeof(GameObject), true) as GameObject;
                    if (group.gameObject == null)
                    { // Should default to the current object
                        group.gameObject = mainTarget.gameObject;
                    }

                    int i = 0;
                    foreach (LeanTweenItem item in group.itemList)
                    {
                        if (item.actionStr == null)
                        {
                            item.actionStr = "MOVE";
                        }
                        //if (item.actionStr != null)
                        // {

                        #region TweenStatus and DeleteButton
                        EditorGUILayout.Separator();
                        GUI.color = LTEditor.Shared.colorTweenName;
                        EditorGUILayout.BeginHorizontal();

                        string actionName = LTVisualShared.methodLabels[LTVisualShared.actionIndex(item)];
                        item.foldout = EditorGUILayout.Foldout(item.foldout, "", LTEditor.Shared.styleItemFoldout);

                        string itemStatus = actionName + ": " + (item.delay) + "s - " + (item.delay + item.duration) + "s";
                        if (item.doesLoop)
                        {
                            if (item.loopCount < 0)
                            {
                                itemStatus += "    (* %%)";
                            }
                            else
                            {
                                itemStatus += "    (* " + item.loopCount + ")";
                            }
                        }

                        bool tweenClicked = GUILayout.Button(itemStatus, LTEditor.Shared.styleItemButton);
                        if (tweenClicked)
                        {
                            item.foldout = !item.foldout;
                        }

                        GUI.color = LTEditor.Shared.colorDelete;
                        deleted   = GUILayout.Button("Delete", LTEditor.Shared.styleDeleteGroupButton);
                        EditorGUILayout.EndHorizontal();
                        GUI.color = Color.white;
                        #endregion

                        if (clicked)
                        {
                            item.foldout = !item.foldout;
                        }
                        if (deleted)
                        {
                            Undo.RecordObject(mainTarget, "Removing tween item");
                            group.itemList.Remove(item);

                            break;
                        }

                        if (item.foldout)
                        {
                            #region Action Field
                            EditorGUILayout.BeginHorizontal();

                            EditorGUILayout.LabelField("    Action", GUILayout.Width(70));
                            int  atualIndex     = LTVisualShared.actionIndex(item);
                            int  newActionIndex = EditorGUILayout.Popup("", atualIndex, LTVisualShared.methodLabels, GUILayout.Width(160));
                            bool changeAction   = false;
                            if (newActionIndex != atualIndex)
                            {
                                Undo.RecordObject(mainTarget, "Change action index");
                                LTVisualShared.SetActionIndex(item, newActionIndex);
                                changeAction     = true;
                                item.alignToPath = false;
                            }
                            TweenAction a = (TweenAction)Enum.Parse(typeof(TweenAction), item.actionStr, true);
                            item.action     = a;
                            item.actionLast = (int)item.action;

                            EditorGUILayout.EndHorizontal();
                            #endregion

                            item.gameObject = EditorGUILayout.ObjectField("    GameObject", item.gameObject, typeof(GameObject), true /*, GUILayout.Width(250)*/) as GameObject;
                            if (item.gameObject == null)
                            { // Should default to the current object
                                item.gameObject = mainTarget.gameObject;
                            }

                            // Path
                            bool isBezier = a == TweenAction.MoveBezier || a == TweenAction.MoveBezierLocal || a == TweenAction.CanvasMoveBezier ||
                                            a == TweenAction.CanvasMoveBezierLocal;
                            bool isSpline = a == TweenAction.MoveSplineLocal || a == TweenAction.MoveSpline;
                            bool isCurve  = false;
                            if (isBezier || isSpline)
                            {
                                isCurve = true;

                                if (isBezier)
                                {
                                    item.bezierPath = EditorGUILayout.ObjectField("    LeanTweenPath:", item.bezierPath, typeof(LeanTweenPath), true) as LeanTweenPath;
                                }
                                else
                                {
                                    item.splinePath = EditorGUILayout.ObjectField("    LeanTweenPath:", item.splinePath, typeof(LeanTweenPath), true) as LeanTweenPath;
                                }

                                EditorGUILayout.BeginHorizontal();
                                EditorGUILayout.LabelField("   Orient to Path", GUILayout.Width(95));
                                Change(ref item.orientToPath, EditorGUILayout.Toggle(item.orientToPath), mainTarget, "Orient to Path");

                                EditorGUILayout.LabelField(new GUIContent("    Align to Path", "Click to align the object with the start of the path."),
                                                           GUILayout.Width(90));
                                bool align   = EditorGUILayout.Toggle(item.alignToPath);
                                bool changed = align != wasAligned ? true : false;
                                wasAligned = align;

                                Undo.RecordObject(mainTarget, "Aligned to path");
                                item.alignToPath = align;

                                if (a != TweenAction.MoveBezierLocal && a != TweenAction.MoveSplineLocal && a != TweenAction.CanvasMoveBezierLocal)
                                {
                                    if (item.alignToPath)
                                    {
                                        if (isBezier)
                                        {
                                            LTBezierPath lTBezier = new LTBezierPath(item.bezierPath.vec3);

                                            Vector3 pt0 = lTBezier.Point(0.002f);
                                            mainTarget.transform.position = pt0;

                                            Vector3 added = lTBezier.Point(0.003f);
                                            Vector3 v3Dir = added - mainTarget.transform.position;
                                            float   angle = Mathf.Atan2(v3Dir.y, v3Dir.x) * Mathf.Rad2Deg;
                                            mainTarget.transform.eulerAngles = new Vector3(0, 0, angle);
                                        }
                                        else
                                        {
                                            mainTarget.transform.position = item.splinePath.splineVector()[0];
                                        }
                                    }
                                    else
                                    {
                                        if (changed && !changeAction)
                                        {
                                            mainTarget.transform.position    = notAlignedPosition;
                                            mainTarget.transform.eulerAngles = notAlignedRotation;
                                        }
                                        else
                                        {
                                            notAlignedPosition = mainTarget.transform.position;
                                            notAlignedRotation = mainTarget.transform.eulerAngles;
                                        }
                                    }
                                }

                                if (isBezier)
                                {
                                    EditorGUILayout.LabelField("    2D Path", GUILayout.Width(65));
                                    Change(ref item.isPath2d, EditorGUILayout.Toggle(item.isPath2d), mainTarget, "2D Path");
                                }

                                EditorGUILayout.EndHorizontal();
                            }

                            if (isCurve == false)
                            {
                                bool isVector = a == TweenAction.Move || a == TweenAction.MoveLocal || a == TweenAction.MoveAdd || a == TweenAction.CanvasMove ||
                                                a == TweenAction.CanvasMoveAdd || a == TweenAction.Scale || a == TweenAction.ScaleAdd || a == TweenAction.CanvasScale ||
                                                a == TweenAction.CanvasScaleAdd || a == TweenAction.CanvasSize || a == TweenAction.DelayedSound || a == TweenAction.CanvasRotate ||
                                                a == TweenAction.CanvasSizeAdd || a == TweenAction.RotateAdd || a == TweenAction.CanvasRotateAdd || a == TweenAction.CanvasRotateLocal ||
                                                a == TweenAction.Rotate || a == TweenAction.RotateLocal;

                                bool isColor = a == TweenAction.Color || a == TweenAction.CanvasColor || a == TweenAction.CanvasTextColor || a == TweenAction.ColorGroup;

                                bool isAlpha = a == TweenAction.Alpha || a == TweenAction.AlphaVertex || a == TweenAction.CanvasAlpha || a == TweenAction.CanvasTextAlpha ||
                                               a == TweenAction.CanvasGroupAlpha || a == TweenAction.AlphaGroup;

                                bool isPlay   = a == TweenAction.CanvasPlaySprite;
                                bool usesFrom = !isColor && !isPlay;

                                // From Values
                                EditorGUILayout.BeginHorizontal();
                                if (usesFrom)
                                { // Not a Color tween
                                    EditorGUILayout.LabelField(new GUIContent("    From", "Specify where the tween starts from, otherwise it will start from it's current value"), GUILayout.Width(50));
                                    LeanTweenBetween between = EditorGUILayout.Toggle("", item.between == LeanTweenBetween.FromTo, GUILayout.Width(30)) ? LeanTweenBetween.FromTo : LeanTweenBetween.To;
                                    if (between != item.between)
                                    {
                                        Undo.RecordObject(mainTarget, "Changing to from/to");
                                        item.between = between;
                                    }
                                }
                                if (item.between == LeanTweenBetween.FromTo)
                                {
                                    if (isVector)
                                    {
                                        //										item.from = EditorGUILayout.Vector3Field("", item.from);
                                        Change(ref item.from, EditorGUILayout.Vector3Field("", item.from), mainTarget, "Changing from");
                                    }
                                    else if (isColor)
                                    {
                                    }
                                    else
                                    {
                                        vec   = Vector3.zero;
                                        vec.x = EditorGUILayout.FloatField("From", item.from.x);

                                        if (vec.x != item.from.x)
                                        {
                                            Undo.RecordObject(mainTarget, "Setting new from value");
                                            item.from = vec;
                                        }
                                    }
                                }
                                EditorGUILayout.EndHorizontal();

                                // To Values
                                EditorGUILayout.BeginHorizontal();
                                if (isVector)
                                {
                                    EditorGUILayout.LabelField("    To", GUILayout.Width(85));
                                    Change(ref item.to, EditorGUILayout.Vector3Field("", item.to), mainTarget, "Changing vector3 to");
                                }
                                else if (isColor)
                                {
                                    EditorGUILayout.LabelField("    To", GUILayout.Width(85));
                                    Change(ref item.colorTo, EditorGUILayout.ColorField("", item.colorTo), mainTarget, "Change color to");
                                }
                                else if (isPlay)
                                {
                                    item.doesLoop = true;

                                    GUILayout.Space(24);
                                    item.spritesMaximized = EditorGUILayout.Foldout(item.spritesMaximized, "Sprites");
                                    if (item.spritesMaximized)
                                    {
                                        EditorGUILayout.LabelField("Add", GUILayout.Width(35));
                                        UnityEngine.Sprite sprite = EditorGUILayout.ObjectField("", null, typeof(UnityEngine.Sprite), true, GUILayout.Width(150)) as UnityEngine.Sprite;
                                        if (sprite != null)
                                        {
                                            Undo.RecordObject(mainTarget, "Adding a sprite");
                                            item.sprites = Add(item.sprites, sprite);
                                        }
                                        EditorGUILayout.Separator();
                                        EditorGUILayout.Separator();
                                        EditorGUILayout.Separator();
                                    }
                                }
                                else
                                {
                                    vec = Vector3.zero;
                                    EditorGUILayout.LabelField("    To", GUILayout.Width(85));

                                    float setToX;
                                    if (isAlpha)
                                    {
                                        setToX = EditorGUILayout.Slider("", item.to.x, 0, 1f);
                                    }
                                    else
                                    {
                                        setToX = EditorGUILayout.FloatField("", item.to.x);
                                    }


                                    Undo.RecordObject(mainTarget, "Setting x to");
                                    vec.x   = setToX;
                                    item.to = vec;
                                }
                                EditorGUILayout.EndHorizontal();

                                // Sprite List
                                if (isPlay && item.spritesMaximized)
                                {
                                    for (int j = 0; j < item.sprites.Length; j++)
                                    {
                                        EditorGUILayout.BeginHorizontal();
                                        EditorGUILayout.LabelField("        sprite" + j, GUILayout.Width(85));
                                        item.sprites[j] = EditorGUILayout.ObjectField("", item.sprites[j], typeof(UnityEngine.Sprite), true) as UnityEngine.Sprite;
                                        GUI.color       = LTEditor.Shared.colorDelete;
                                        deleted         = GUILayout.Button("Delete", LTEditor.Shared.styleDeleteButton);
                                        GUI.color       = Color.white;
                                        EditorGUILayout.EndHorizontal();

                                        if (deleted)
                                        {
                                            Undo.RecordObject(mainTarget, "Removing sprite");
                                            item.sprites = Remove(item.sprites, j);
                                            break;
                                        }
                                    }
                                }
                            }
                            EditorGUILayout.Space();

                            // Easing
                            if (a == TweenAction.DelayedSound)
                            {
                                Change(ref item.audioClip, EditorGUILayout.ObjectField("    AudioClip:", item.audioClip, typeof(AudioClip), true) as AudioClip, mainTarget, "set audio clip");
                            }
                            else
                            {
                                EditorGUILayout.BeginHorizontal();
                                EditorGUILayout.LabelField("    Easing", GUILayout.Width(70));

                                int easeIndex    = LTVisualShared.EaseIndex(item);
                                int easeIndexNew = EditorGUILayout.Popup("", easeIndex, LTVisualShared.easeStrMapping, GUILayout.Width(128));
                                if (easeIndex != easeIndexNew)
                                {
                                    Undo.RecordObject(mainTarget, "changing easing type");
                                    LTVisualShared.SetEaseIndex(item, easeIndexNew);
                                }

                                EditorGUILayout.Separator();
                                EditorGUILayout.EndHorizontal();

                                if (item.ease == LeanTweenType.AnimationCurve)
                                {
                                    Undo.RecordObject(mainTarget, "changing easing type anim curve");
                                    item.animationCurve = EditorGUILayout.CurveField("    Ease Curve", item.animationCurve);
                                }
                                EditorGUILayout.Space();
                            }
                            if (item.ease >= LeanTweenType.Once && item.ease < LeanTweenType.AnimationCurve)
                            {
                                EditorGUILayout.LabelField(new GUIContent("   ERROR: You Specified a non-easing type", "Select a type with the value 'Ease' in front of it (or linear)"), EditorStyles.boldLabel);
                            }

                            // Speed

                            EditorGUILayout.BeginHorizontal();
                            Change(ref item.useSpeed, EditorGUILayout.Toggle("    Use Speed", item.useSpeed), mainTarget, "toggled use speed");
                            EditorGUILayout.EndHorizontal();

                            // Timing
                            if (i > 0)
                            {
                                Change(ref item.alignWithPrevious, EditorGUILayout.Toggle(new GUIContent("    Align with Previous", "When you change the timing of a previous tween, this tween's timing will be adjusted to follow afterwards."), item.alignWithPrevious),
                                       mainTarget, "toggle align with previous");
                            }
                            EditorGUILayout.BeginHorizontal();
                            if (i > 0 && item.alignWithPrevious)
                            {
                                Change(ref item.delay, addedTweenDelay, mainTarget, "change delay");
                                EditorGUILayout.LabelField("    Delay:   " + item.delay, GUILayout.Width(50));
                            }
                            else
                            {
                                EditorGUILayout.LabelField("    Delay", GUILayout.Width(50));
                                Change(ref item.delay, EditorGUILayout.FloatField("", item.delay, GUILayout.Width(50)), mainTarget, "change delay");
                            }

                            if (a == TweenAction.DelayedSound)
                            {
                                EditorGUILayout.LabelField("Volume", GUILayout.Width(50));
                                Change(ref item.duration, EditorGUILayout.FloatField("", item.duration, GUILayout.Width(50)), mainTarget, "change volume");
                            }
                            else if (a == TweenAction.CanvasPlaySprite)
                            {
                                EditorGUILayout.LabelField("Frame Rate", GUILayout.Width(85));
                                Change(ref item.frameRate, EditorGUILayout.FloatField("", item.frameRate, GUILayout.Width(50)), mainTarget, "change volume");
                            }
                            else if (item.useSpeed)
                            {
                                EditorGUILayout.LabelField("Speed", GUILayout.Width(50));
                                Change(ref item.speed, EditorGUILayout.FloatField("", item.speed, GUILayout.Width(50)), mainTarget, "change speed");
                            }
                            else
                            {
                                EditorGUILayout.LabelField("Time", GUILayout.Width(50));
                                float newDuration = EditorGUILayout.FloatField("", item.duration, GUILayout.Width(50));
                                if (newDuration <= 0.0f)
                                {
                                    newDuration = 0.0001f;
                                }
                                Change(ref item.duration, newDuration, mainTarget, "change timing");
                            }
                            EditorGUILayout.Separator();
                            EditorGUILayout.EndHorizontal();


                            // Repeat
                            EditorGUILayout.Space();
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("    Loops", GUILayout.Width(50));
                            Change(ref item.doesLoop, EditorGUILayout.Toggle("", item.doesLoop, GUILayout.Width(50)), mainTarget, "Toggled does loop");

                            if (item.doesLoop)
                            {
                                EditorGUILayout.LabelField(new GUIContent("Repeat", "-1 repeats infinitely"), GUILayout.Width(50));
                                Change(ref item.loopCount, EditorGUILayout.IntField(new GUIContent("", ""), item.loopCount, GUILayout.Width(50)), mainTarget, "changed loop count");
                                if (item.loopCount == 0 || item.loopCount == 1)
                                {
                                    item.loopCount = 2;
                                }
                                EditorGUILayout.LabelField(new GUIContent("    Wrap", "How the tween repeats\nClamp: restart from beginning\nPingpong: goes back and forth\nAdd: not reset when finished."), GUILayout.Width(50));
                                int index = (int)item.loopType - 1; // -1 cause Once is not in list Normal list -> {Once, Clamp, PingPong, Add};
                                index = EditorGUILayout.Popup("", index, new string[] { "Clamp", "Ping Pong", "Add" }, GUILayout.Width(70));
                                EditorGUILayout.EndHorizontal();

                                LoopType newLoopType = LoopType.Clamp;
                                switch (index)
                                {
                                case 0:
                                    newLoopType = LoopType.Clamp;
                                    break;

                                case 1:
                                    newLoopType = LoopType.PingPong;
                                    break;

                                case 2:
                                    newLoopType = LoopType.Add;
                                    break;
                                }

                                if (newLoopType != item.loopType)
                                {
                                    Undo.RecordObject(mainTarget, "change loop type");
                                    item.loopType = newLoopType;
                                }

                                EditorGUILayout.BeginHorizontal();
                                EditorGUILayout.LabelField(new GUIContent("    LoopDelay", "Delay between each loop of this tween."), GUILayout.Width(90));
                                Change(ref item.loopDelay, EditorGUILayout.FloatField("", item.loopDelay, GUILayout.Width(50)), mainTarget, "Changed loop delay");
                                if (item.loopDelay < 0)
                                {
                                    item.loopDelay = 0;
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                            else
                            {
                                EditorGUILayout.EndHorizontal();
                            }

                            EditorGUILayout.Separator();

                            EditorGUILayout.BeginHorizontal();
                            //EditorGUILayout.LabelField("", GUILayout.Width(100));

                            item.callbackFoldout = EditorGUILayout.Foldout(item.callbackFoldout, "", LTEditor.Shared.styleCallbackFoldout);

                            GUI.color = Color.gray;
                            bool callbacksClicked = GUILayout.Button("Callbacks", LTEditor.Shared.styleCallbackButton);
                            GUI.color = Color.white;

                            EditorGUILayout.EndHorizontal();

                            if (callbacksClicked)
                            {
                                item.callbackFoldout = !item.callbackFoldout;
                            }

                            if (item.callbackFoldout)
                            {
                                #region Draw UnityEvents
                                SerializedProperty prop = serializedObject.GetIterator();
                                while (prop.NextVisible(true))
                                {
                                    string itemPath     = $"groupList.Array.data[{groupIndex}].itemList.Array.data[{i}]";
                                    bool   drawProperty = (prop.propertyPath == itemPath + ".onCompleteLoop") ||
                                                          (prop.propertyPath == itemPath + ".onCompleteItem");

                                    if (drawProperty)
                                    {
                                        EditorGUILayout.Separator();

                                        EditorGUILayout.BeginHorizontal();
                                        EditorGUILayout.LabelField("", GUILayout.Width(28));
                                        EditorGUILayout.PropertyField(prop);
                                        EditorGUILayout.EndHorizontal();
                                    }
                                }
                                #endregion
                            }

                            addedTweenDelay = item.duration + item.delay + (item.loopDelay * item.loopCount);

                            EditorGUILayout.Separator();
                            EditorGUILayout.Separator();

                            i++;
                        }
                    }
                    EditorGUILayout.Separator();
                    if (ShowLeftButton("+ Tween", LTEditor.Shared.colorAddTween, 15))
                    {
                        Undo.RecordObject(mainTarget, "adding another tween");
                        LeanTweenItem newItem = new LeanTweenItem(addedTweenDelay);
                        //newItem.alignWithPrevious = true;
                        group.itemList.Add(newItem);
                    }
                    addedGroupDelay += addedTweenDelay;

                    EditorGUILayout.Separator();
                }
                overallDelay += mainTarget.GetGroupEndTime(group);
                groupIndex++;
            }

            EditorGUILayout.Separator();
            if (ShowLeftButton("+ Group", LTEditor.Shared.colorAddGroup))
            {
                Undo.RecordObject(mainTarget, "adding another group");
                // Debug.Log("adding group with delay:"+addedGroupDelay);
                mainTarget.groupList.Add(new LeanTweenGroup(addedGroupDelay));
            }

            if (mainTarget.generateCode && !mainTarget.isSimulating)
            {
                EditorGUILayout.Separator();
                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("Generated C# Code", EditorStyles.boldLabel);
                EditorGUILayout.BeginHorizontal();
                if (Application.isPlaying == false)
                {
                    scrollCodeViewPos = EditorGUILayout.BeginScrollView(scrollCodeViewPos, GUILayout.Height(150));

                    EditorGUILayout.TextArea(mainTarget.BuildAllTweens(true, true), LTEditor.Shared.styleCodeTextArea);

                    EditorGUILayout.EndScrollView();
                }
                else
                {
                    EditorGUILayout.LabelField("    Not available during runtime");
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUI.EndChangeCheck();
            serializedObject.ApplyModifiedProperties();
        }
示例#28
0
    //this function use vector3's first element
    public static void ValueTo(GameObject target, float startVal, float endVal, float time, float delay, TweenAction updateAction, TweenAction completeAction = null, EaseType easeType = EaseType.Linear)
    {
        if (updateAction == null)
        {
            JDebugger.Log("JTween ValueTo updateAction must be registered");
            return;
        }

        JTweenFactor factor = new JTweenFactor(TweenType.Value, easeType, target, new Vector3(startVal, 0, 0), new Vector3(endVal, 0, 0), time, delay, updateAction, completeAction);

        _factorList.Add(factor);
    }
示例#29
0
 public void SelectNumberRunTween()
 {
     SelectedTweenAction = new NumberRunTweenAction();
 }
示例#30
0
 public void SelectKickTween()
 {
     SelectedTweenAction = new KickTweenAction();
 }
示例#31
0
    public LTDescr setCanvasColor()
    {
        this.type = TweenAction.CANVAS_COLOR;
        this.initInternal = ()=>{
            this.uiImage = trans.gameObject.GetComponent<UnityEngine.UI.Image>();
            if(this.uiImage != null){
                this.setFromColor( this.uiImage.color );
            }else{
                this.setFromColor( Color.white );
            }
        };
        this.easeInternal = ()=>{
            newVect = easeMethod();
            val = newVect.x;
            Color toColor = tweenColor(this, val);
            this.uiImage.color = toColor;
            if (dt!=0f && this._optional.onUpdateColor != null)
                this._optional.onUpdateColor(toColor);

            if(this.useRecursion)
                colorRecursive(this.rectTransform, toColor);
        };
        return this;
    }
示例#32
0
 public void SelectShakeAngleTween()
 {
     SelectedTweenAction = new ShakeAngleTweenAction();
 }
示例#33
0
 public LTDescr setCanvasMove()
 {
     this.type = TweenAction.CANVAS_MOVE;
     this.initInternal = ()=>{ this.fromInternal = this.rectTransform.anchoredPosition3D; };
     this.easeInternal = ()=>{ this.rectTransform.anchoredPosition3D = easeMethod(); };
     return this;
 }
示例#34
0
 public LTDescr setCallback()
 {
     this.type = TweenAction.CALLBACK;
     this.initInternal = ()=>{};
     this.easeInternal = this.callback;
     return this;
 }
示例#35
0
 public LTDescr setCanvasPlaySprite()
 {
     this.type = TweenAction.CANVAS_PLAYSPRITE;
     this.initInternal = ()=>{
         this.uiImage = trans.gameObject.GetComponent<UnityEngine.UI.Image>();
         this.fromInternal.x = 0f;
     };
     this.easeInternal = ()=>{
         newVect = easeMethod();
         val = newVect.x;
         int frame = (int)Mathf.Round( val );
         this.uiImage.sprite = this.sprites[ frame ];
     };
     return this;
 }
示例#36
0
    public LTDescr setColor()
    {
        this.type = TweenAction.COLOR;
        this.initInternal = ()=>{
            #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
            if(trans.gameObject.renderer){
            this.setFromColor( trans.gameObject.renderer.material.color );
            }else if(trans.childCount>0){
            foreach (Transform child in trans) {
            if(child.gameObject.renderer!=null){
            this.setFromColor( child.gameObject.renderer.material.color );
            break;
            }
            }
            }
            #else
            SpriteRenderer renColor = trans.gameObject.GetComponent<SpriteRenderer>();
            if(renColor!=null){
                this.setFromColor( renColor.color );
            }else{
                if(trans.gameObject.GetComponent<Renderer>()!=null && trans.gameObject.GetComponent<Renderer>().material.HasProperty("_Color")){
                    Color col = trans.gameObject.GetComponent<Renderer>().material.color;
                    this.setFromColor( col );
                }else if(trans.gameObject.GetComponent<Renderer>()!=null && trans.gameObject.GetComponent<Renderer>().material.HasProperty("_TintColor")){
                    Color col = trans.gameObject.GetComponent<Renderer>().material.GetColor ("_TintColor");
                    this.setFromColor( col );
                }else if(trans.childCount>0){
                    foreach (Transform child in trans) {
                        if(child.gameObject.GetComponent<Renderer>()!=null){
                            Color col = child.gameObject.GetComponent<Renderer>().material.color;
                            this.setFromColor( col );
                            break;
                        }
                    }
                }
            }
            #endif
        };
        this.easeInternal = ()=>{
            newVect = easeMethod();
            val = newVect.x;
            Color toColor = tweenColor(this, val);

            #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2

            if(this.spriteRen!=null){
                this.spriteRen.color = toColor;
                colorRecursiveSprite( trans, toColor);
            }else{
            #endif
                // Debug.Log("val:"+val+" tween:"+tween+" tween.diff:"+tween.diff);
                if(this.type==TweenAction.COLOR)
                    colorRecursive(trans, toColor, this.useRecursion);

                #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2
            }
                #endif
            if(dt!=0f && this._optional.onUpdateColor!=null){
                this._optional.onUpdateColor(toColor);
            }else if(dt!=0f && this._optional.onUpdateColorObject!=null){
                this._optional.onUpdateColorObject(toColor, this._optional.onUpdateParam);
            }
        };
        return this;
    }
示例#37
0
 public LTDescr setCanvasScale()
 {
     this.type = TweenAction.CANVAS_SCALE;
     this.initInternal = ()=>{ this.from = this.rectTransform.localScale; };
     this.easeInternal = ()=>{ this.rectTransform.localScale = easeMethod(); };
     return this;
 }
示例#38
0
 public LTDescr setGUIAlpha()
 {
     this.type = TweenAction.GUI_ALPHA;
     this.initInternal = ()=>{ this.fromInternal.x = this._optional.ltRect.alpha; };
     this.easeInternal = ()=>{ this._optional.ltRect.alpha = easeMethod().x; };
     return this;
 }
示例#39
0
    public LTDescr setTextColor()
    {
        this.type = TweenAction.TEXT_COLOR;
        this.initInternal = ()=>{
            this.uiText = trans.gameObject.GetComponent<UnityEngine.UI.Text>();
            this.setFromColor( this.uiText != null ? this.uiText.color : Color.white );
        };
        this.easeInternal = ()=>{
            newVect = easeMethod();
            val = newVect.x;
            Color toColor = tweenColor(this, val);
            this.uiText.color = toColor;
            if (dt!=0f && this._optional.onUpdateColor != null)
                this._optional.onUpdateColor(toColor);

            if(this.useRecursion && trans.childCount>0)
                textColorRecursive(this.trans, toColor);
        };
        return this;
    }
示例#40
0
    public LTDescr setGUIRotate()
    {
        this.type = TweenAction.GUI_ROTATE;
        this.initInternal = ()=>{ if(this._optional.ltRect.rotateEnabled==false){
                this._optional.ltRect.rotateEnabled = true;
                this._optional.ltRect.resetForRotation();
            }

            this.fromInternal.x = this._optional.ltRect.rotation;
        };
        this.easeInternal = ()=>{ this._optional.ltRect.rotation = easeMethod().x; };
        return this;
    }
示例#41
0
 public LTDescr setAlphaVertex()
 {
     this.type = TweenAction.ALPHA_VERTEX;
     this.initInternal = ()=>{ this.fromInternal.x = trans.GetComponent<MeshFilter>().mesh.colors32[0].a; };
     this.easeInternal = ()=>{
         newVect = easeMethod();
         val = newVect.x;
         Mesh mesh = trans.GetComponent<MeshFilter>().mesh;
         Vector3[] vertices = mesh.vertices;
         Color32[] colors = new Color32[vertices.Length];
         if (colors.Length == 0){ //MaxFW fix: add vertex colors if the mesh doesn't have any
             Color32 transparentWhiteColor32 = new Color32(0xff, 0xff, 0xff, 0x00);
             colors = new Color32[mesh.vertices.Length];
             for (int k=0; k<colors.Length; k++)
                 colors[k] = transparentWhiteColor32;
             mesh.colors32 = colors;
         }// fix end
         Color32 c = mesh.colors32[0];
         c = new Color( c.r, c.g, c.b, val);
         for (int k= 0; k < vertices.Length; k++)
             colors[k] = c;
         mesh.colors32 = colors;
     };
     return this;
 }
示例#42
0
 public void SelectFadeInOutTweens()
 {
     SelectedTweenAction = new FadeTweensAction();
 }
示例#43
0
    public LTDescr setCallbackColor()
    {
        this.type = TweenAction.CALLBACK_COLOR;
        this.initInternal = ()=>{ this.diff = new Vector3(1.0f,0.0f,0.0f); };
        this.easeInternal = ()=>{
            newVect = easeMethod();
            val = newVect.x;
            Color toColor = tweenColor(this, val);

            #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2
            if(this.spriteRen!=null){
                this.spriteRen.color = toColor;
                colorRecursiveSprite( trans, toColor);
            }else{
            #endif
                // Debug.Log("val:"+val+" tween:"+tween+" tween.diff:"+tween.diff);
                if(this.type==TweenAction.COLOR)
                    colorRecursive(trans, toColor, this.useRecursion);

                #if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2
            }
                #endif
            if(dt!=0f && this._optional.onUpdateColor!=null){
                this._optional.onUpdateColor(toColor);
            }else if(dt!=0f && this._optional.onUpdateColorObject!=null){
                this._optional.onUpdateColorObject(toColor, this._optional.onUpdateParam);
            }
        };
        return this;
    }
 /// <summary>
 /// Instantiates LeanTweenGroup by making a copy of group.
 /// </summary>
 /// <param name="group">Group.</param>
 public LeanTweenItem(LeanTweenItem item)
 {
     name = item.name;
     action = item.action;
     between = item.between;
     ease = item.ease;
     from = item.from;
     to = item.to;
     axis = item.axis;
     duration = item.duration;
     delay = item.delay;
     foldout = item.foldout;
 }
示例#45
0
 public LTDescr setDelayedSound()
 {
     this.type = TweenAction.DELAYED_SOUND;
     this.initInternal = ()=>{ this.hasExtraOnCompletes = true; };
     this.easeInternal = this.callback;
     return this;
 }
	public static void update()
	{
		if (frameRendered != Time.frameCount)
		{ // make sure update is only called once per frame
			init();

#if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5
		dtEstimated = Time.realtimeSinceStartup - previousRealTime;
		if(dtEstimated>0.2f) // a catch put in, when at the start sometimes this number can grow unrealistically large
			dtEstimated = 0.2f;
		previousRealTime = Time.realtimeSinceStartup;
#else
			dtEstimated = Time.unscaledDeltaTime;
#endif

			dtActual = Time.deltaTime;
			maxTweenReached = 0;
			finishedCnt = 0;
			// if(tweenMaxSearch>1500)
			// Debug.Log("tweenMaxSearch:"+tweenMaxSearch +" maxTweens:"+maxTweens);
			for (int i = 0; i <= tweenMaxSearch && i < maxTweens; i++)
			{

				//if(i==0 && tweens[i].toggle)
				//	Debug.Log("tweens["+i+"]"+tweens[i]+" dt:"+dt);
				if (tweens[i].toggle)
				{
					maxTweenReached = i;
					tween = tweens[i];
					trans = tween.trans;
					timeTotal = tween.time;
					tweenAction = tween.type;

					/*if(trans.gameObject.name=="Main Camera"){
						Debug.Log("main tween:"+tween+" i:"+i);
					}*/

					if (tween.useEstimatedTime)
					{
						dt = dtEstimated;
					}
					else if (tween.useFrames)
					{
						dt = 1;
					}
					else if (tween.useManualTime)
					{
						dt = dtManual;
					}
					else if (tween.direction == 0f)
					{
						dt = 0f;
					}
					else
					{
						dt = dtActual;
					}

					if (trans == null)
					{
						removeTween(i);
						continue;
					}
					// Debug.Log("i:"+i+" tween:"+tween+" dt:"+dt);

					// Check for tween finished
					isTweenFinished = false;
					if (tween.delay <= 0)
					{
						if ((tween.passed + dt > tween.time && tween.direction > 0.0f))
						{
							// Debug.Log("i:"+i+" passed:"+tween.passed+" dt:"+dt+" time:"+tween.time+" dir:"+tween.direction);
							isTweenFinished = true;
							tween.passed = tween.time; // Set to the exact end time so that it can finish tween exactly on the end value
						}
						else if (tween.direction < 0.0f && tween.passed - dt < 0.0f)
						{
							isTweenFinished = true;
							tween.passed = Mathf.Epsilon;
						}
					}

					if (!tween.hasInitiliazed && ((tween.passed == 0.0 && tween.delay == 0.0) || tween.passed > 0.0))
					{
						tween.init();
					}

					if (tween.delay <= 0)
					{
						// Move Values
						if (timeTotal <= 0f)
						{
							//Debug.LogError("time total is zero Time.timeScale:"+Time.timeScale+" useEstimatedTime:"+tween.useEstimatedTime);
							ratioPassed = 1f;
						}
						else
						{
							ratioPassed = tween.passed / timeTotal;
						}

						if (ratioPassed > 1.0f)
						{
							ratioPassed = 1.0f;
						}
						else if (ratioPassed < 0f)
						{
							ratioPassed = 0f;
						}
						// Debug.Log("action:"+tweenAction+" ratioPassed:"+ratioPassed + " timeTotal:" + timeTotal + " tween.passed:"+ tween.passed +" dt:"+dt);

						if (tweenAction >= TweenAction.MOVE_X && tweenAction < TweenAction.MOVE)
						{
							if (tween.animationCurve != null)
							{
								val = tweenOnCurve(tween, ratioPassed);
							}
							else
							{
								switch (tween.tweenType)
								{
									case LeanTweenType.linear:
										val = tween.from.x + tween.diff.x * ratioPassed; break;
									case LeanTweenType.easeOutQuad:
										val = easeOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed); break;
									case LeanTweenType.easeInQuad:
										val = easeInQuadOpt(tween.from.x, tween.diff.x, ratioPassed); break;
									case LeanTweenType.easeInOutQuad:
										val = easeInOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed); break;
									case LeanTweenType.easeInCubic:
										val = easeInCubic(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeOutCubic:
										val = easeOutCubic(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInOutCubic:
										val = easeInOutCubic(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInQuart:
										val = easeInQuart(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeOutQuart:
										val = easeOutQuart(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInOutQuart:
										val = easeInOutQuart(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInQuint:
										val = easeInQuint(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeOutQuint:
										val = easeOutQuint(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInOutQuint:
										val = easeInOutQuint(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInSine:
										val = easeInSine(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeOutSine:
										val = easeOutSine(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInOutSine:
										val = easeInOutSine(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInExpo:
										val = easeInExpo(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeOutExpo:
										val = easeOutExpo(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInOutExpo:
										val = easeInOutExpo(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInCirc:
										val = easeInCirc(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeOutCirc:
										val = easeOutCirc(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInOutCirc:
										val = easeInOutCirc(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInBounce:
										val = easeInBounce(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeOutBounce:
										val = easeOutBounce(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInOutBounce:
										val = easeInOutBounce(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInBack:
										val = easeInBack(tween.from.x, tween.to.x, ratioPassed, tween.overshoot); break;
									case LeanTweenType.easeOutBack:
										val = easeOutBack(tween.from.x, tween.to.x, ratioPassed, tween.overshoot); break;
									case LeanTweenType.easeInOutBack:
										val = easeInOutBack(tween.from.x, tween.to.x, ratioPassed, tween.overshoot); break;
									case LeanTweenType.easeInElastic:
										val = easeInElastic(tween.from.x, tween.to.x, ratioPassed, tween.overshoot, tween.period); break;
									case LeanTweenType.easeOutElastic:
										val = easeOutElastic(tween.from.x, tween.to.x, ratioPassed, tween.overshoot, tween.period); break;
									case LeanTweenType.easeInOutElastic:
										val = easeInOutElastic(tween.from.x, tween.to.x, ratioPassed, tween.overshoot, tween.period); break;
									case LeanTweenType.punch:
									case LeanTweenType.easeShake:
										if (tween.tweenType == LeanTweenType.punch)
										{
											tween.animationCurve = LeanTween.punch;
										}
										else if (tween.tweenType == LeanTweenType.easeShake)
										{
											tween.animationCurve = LeanTween.shake;
										}
										tween.to.x = tween.from.x + tween.to.x;
										tween.diff.x = tween.to.x - tween.from.x;
										val = tweenOnCurve(tween, ratioPassed); break;
									case LeanTweenType.easeSpring:
										val = spring(tween.from.x, tween.to.x, ratioPassed); break;
									default:
										{
											val = tween.from.x + tween.diff.x * ratioPassed; break;
										}
								}

							}

							// Debug.Log("from:"+from+" val:"+val+" ratioPassed:"+ratioPassed);
							if (tweenAction == TweenAction.MOVE_X)
							{
								trans.position = new Vector3(val, trans.position.y, trans.position.z);
							}
							else if (tweenAction == TweenAction.MOVE_Y)
							{
								trans.position = new Vector3(trans.position.x, val, trans.position.z);
							}
							else if (tweenAction == TweenAction.MOVE_Z)
							{
								trans.position = new Vector3(trans.position.x, trans.position.y, val);
							}
							if (tweenAction == TweenAction.MOVE_LOCAL_X)
							{
								trans.localPosition = new Vector3(val, trans.localPosition.y, trans.localPosition.z);
							}
							else if (tweenAction == TweenAction.MOVE_LOCAL_Y)
							{
								trans.localPosition = new Vector3(trans.localPosition.x, val, trans.localPosition.z);
							}
							else if (tweenAction == TweenAction.MOVE_LOCAL_Z)
							{
								trans.localPosition = new Vector3(trans.localPosition.x, trans.localPosition.y, val);
							}
							else if (tweenAction == TweenAction.MOVE_CURVED)
							{
								if (tween.path.orientToPath)
								{
									if (tween.path.orientToPath2d)
									{
										tween.path.place2d(trans, val);
									}
									else
									{
										tween.path.place(trans, val);
									}
								}
								else
								{
									trans.position = tween.path.point(val);
								}
								// Debug.Log("val:"+val+" trans.position:"+trans.position + " 0:"+ tween.curves[0] +" 1:"+tween.curves[1] +" 2:"+tween.curves[2] +" 3:"+tween.curves[3]);
							}
							else if ((TweenAction)tweenAction == TweenAction.MOVE_CURVED_LOCAL)
							{
								if (tween.path.orientToPath)
								{
									if (tween.path.orientToPath2d)
									{
										tween.path.placeLocal2d(trans, val);
									}
									else
									{
										tween.path.placeLocal(trans, val);
									}
								}
								else
								{
									trans.localPosition = tween.path.point(val);
								}
								// Debug.Log("val:"+val+" trans.position:"+trans.position);
							}
							else if (tweenAction == TweenAction.MOVE_SPLINE)
							{
								if (tween.spline.orientToPath)
								{
									if (tween.spline.orientToPath2d)
									{
										tween.spline.place2d(trans, val);
									}
									else
									{
										tween.spline.place(trans, val);
									}
								}
								else
								{
									trans.position = tween.spline.point(val);
								}
							}
							else if (tweenAction == TweenAction.MOVE_SPLINE_LOCAL)
							{
								if (tween.spline.orientToPath)
								{
									if (tween.spline.orientToPath2d)
									{
										tween.spline.placeLocal2d(trans, val);
									}
									else
									{
										tween.spline.placeLocal(trans, val);
									}
								}
								else
								{
									trans.localPosition = tween.spline.point(val);
								}
							}
							else if (tweenAction == TweenAction.SCALE_X)
							{
								trans.localScale = new Vector3(val, trans.localScale.y, trans.localScale.z);
							}
							else if (tweenAction == TweenAction.SCALE_Y)
							{
								trans.localScale = new Vector3(trans.localScale.x, val, trans.localScale.z);
							}
							else if (tweenAction == TweenAction.SCALE_Z)
							{
								trans.localScale = new Vector3(trans.localScale.x, trans.localScale.y, val);
							}
							else if (tweenAction == TweenAction.ROTATE_X)
							{
								trans.eulerAngles = new Vector3(val, trans.eulerAngles.y, trans.eulerAngles.z);
							}
							else if (tweenAction == TweenAction.ROTATE_Y)
							{
								trans.eulerAngles = new Vector3(trans.eulerAngles.x, val, trans.eulerAngles.z);
							}
							else if (tweenAction == TweenAction.ROTATE_Z)
							{
								trans.eulerAngles = new Vector3(trans.eulerAngles.x, trans.eulerAngles.y, val);
							}
							else if (tweenAction == TweenAction.ROTATE_AROUND)
							{
								Vector3 origPos = trans.localPosition;
								Vector3 rotateAroundPt = (Vector3)trans.TransformPoint(tween.point);
								trans.RotateAround(rotateAroundPt, tween.axis, -val);
								Vector3 diff = origPos - trans.localPosition;

								trans.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position
								trans.rotation = tween.origRotation;

								rotateAroundPt = (Vector3)trans.TransformPoint(tween.point);
								trans.RotateAround(rotateAroundPt, tween.axis, val);

								//GameObject cubeMarker = GameObject.Find("TweenRotatePoint");
								//cubeMarker.transform.position = rotateAroundPt;

							}
							else if (tweenAction == TweenAction.ROTATE_AROUND_LOCAL)
							{
								Vector3 origPos = trans.localPosition;
								trans.RotateAround((Vector3)trans.TransformPoint(tween.point), trans.TransformDirection(tween.axis), -val);
								Vector3 diff = origPos - trans.localPosition;

								trans.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position
								trans.localRotation = tween.origRotation;
								Vector3 rotateAroundPt = (Vector3)trans.TransformPoint(tween.point);
								trans.RotateAround(rotateAroundPt, trans.TransformDirection(tween.axis), val);

								//GameObject cubeMarker = GameObject.Find("TweenRotatePoint");
								//cubeMarker.transform.position = rotateAroundPt;

							}
							else if (tweenAction == TweenAction.ALPHA)
							{
#if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2

					    	if(trans.gameObject.renderer){
								foreach(Material mat in trans.gameObject.renderer.materials){
	        						mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val);
	    						}
							}
							if(trans.childCount>0){
								foreach (Transform child in trans) {
									if(child.gameObject.renderer!=null){
										foreach(Material mat in child.gameObject.renderer.materials){
			        						mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val);
			    						}
			    					}
								}
							}

#else

								SpriteRenderer ren = trans.gameObject.GetComponent<SpriteRenderer>();

								if (ren != null)
								{
									ren.color = new Color(ren.color.r, ren.color.g, ren.color.b, val);
								}
								else
								{
									if (trans.gameObject.GetComponent<Renderer>() != null)
									{
										foreach (Material mat in trans.gameObject.GetComponent<Renderer>().materials)
										{
											if (mat.HasProperty("_Color"))
											{
												mat.color = new Color(mat.color.r, mat.color.g, mat.color.b, val);
											}
											else if (mat.HasProperty("_TintColor"))
											{
												Color col = mat.GetColor("_TintColor");
												mat.SetColor("_TintColor", new Color(col.r, col.g, col.b, val));
											}
										}
									}
									if (trans.childCount > 0)
									{
										foreach (Transform child in trans)
										{
											if (child.gameObject.GetComponent<Renderer>() != null)
											{
												foreach (Material mat in child.gameObject.GetComponent<Renderer>().materials)
												{
													mat.color = new Color(mat.color.r, mat.color.g, mat.color.b, val);
												}
											}
										}
									}
								}

#endif
							}
							else if (tweenAction == TweenAction.ALPHA_VERTEX)
							{
								Mesh mesh = trans.GetComponent<MeshFilter>().mesh;
								Vector3[] vertices = mesh.vertices;
								Color32[] colors = new Color32[vertices.Length];
								Color32 c = mesh.colors32[0];
								c = new Color(c.r, c.g, c.b, val);
								for (int k = 0; k < vertices.Length; k++)
								{
									colors[k] = c;
								}
								mesh.colors32 = colors;
							}
							else if (tweenAction == TweenAction.COLOR || tweenAction == TweenAction.CALLBACK_COLOR)
							{
								Color toColor = tweenColor(tween, val);

#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2
								SpriteRenderer ren = trans.gameObject.GetComponent<SpriteRenderer>();
								if (ren != null)
								{
									ren.color = toColor;
								}
								else
								{
#endif
									// Debug.Log("val:"+val+" tween:"+tween+" tween.diff:"+tween.diff);
									if (tweenAction == TweenAction.COLOR)
									{
										if (trans.gameObject.GetComponent<Renderer>() != null)
										{
											foreach (Material mat in trans.gameObject.GetComponent<Renderer>().materials)
											{
												mat.color = toColor;
											}
										}
										if (trans.childCount > 0)
										{
											foreach (Transform child in trans)
											{
												if (child.gameObject.GetComponent<Renderer>() != null)
												{
													foreach (Material mat in child.gameObject.GetComponent<Renderer>().materials)
													{
														mat.color = toColor;
													}
												}
											}
										}
									}
#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2
								}
#endif
								if (dt != 0f && tween.onUpdateColor != null)
								{
									tween.onUpdateColor(toColor);
								}
							}
#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5
							else if (tweenAction == TweenAction.CANVAS_ALPHA)
							{
								Color c = tween.uiImage.color;
								c.a = val;
								tween.uiImage.color = c;
							}
							else if (tweenAction == TweenAction.CANVAS_COLOR)
							{
								Color toColor = tweenColor(tween, val);
								tween.uiImage.color = toColor;
								if (dt != 0f && tween.onUpdateColor != null)
								{
									tween.onUpdateColor(toColor);
								}
							}
							else if (tweenAction == TweenAction.TEXT_ALPHA)
							{
								textAlphaRecursive(trans, val);
							}
							else if (tweenAction == TweenAction.TEXT_COLOR)
							{
								Color toColor = tweenColor(tween, val);
								tween.uiText.color = toColor;
								if (dt != 0f && tween.onUpdateColor != null)
								{
									tween.onUpdateColor(toColor);
								}
								if (trans.childCount > 0)
								{
									foreach (Transform child in trans)
									{
										UnityEngine.UI.Text uiText = child.gameObject.GetComponent<UnityEngine.UI.Text>();
										if (uiText != null)
										{
											uiText.color = toColor;
										}
									}
								}
							}
							else if (tweenAction == TweenAction.CANVAS_ROTATEAROUND)
							{
								// figure out how much the rotation has shifted the object over
								RectTransform rect = tween.rectTransform;
								Vector3 origPos = rect.localPosition;
								rect.RotateAround((Vector3)rect.TransformPoint(tween.point), tween.axis, -val);
								Vector3 diff = origPos - rect.localPosition;

								rect.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position
								rect.rotation = tween.origRotation;
								rect.RotateAround((Vector3)rect.TransformPoint(tween.point), tween.axis, val);
							}
							else if (tweenAction == TweenAction.CANVAS_ROTATEAROUND_LOCAL)
							{
								// figure out how much the rotation has shifted the object over
								RectTransform rect = tween.rectTransform;
								Vector3 origPos = rect.localPosition;
								rect.RotateAround((Vector3)rect.TransformPoint(tween.point), rect.TransformDirection(tween.axis), -val);
								Vector3 diff = origPos - rect.localPosition;

								rect.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position
								rect.rotation = tween.origRotation;
								rect.RotateAround((Vector3)rect.TransformPoint(tween.point), rect.TransformDirection(tween.axis), val);
							}
							else if (tweenAction == TweenAction.CANVAS_PLAYSPRITE)
							{
								int frame = (int)Mathf.Round(val);
								// Debug.Log("frame:"+frame+" val:"+val);
								tween.uiImage.sprite = tween.sprites[frame];
							}
							else if (tweenAction == TweenAction.CANVAS_MOVE_X)
							{
								Vector3 current = tween.rectTransform.anchoredPosition3D;
								tween.rectTransform.anchoredPosition3D = new Vector3(val, current.y, current.z);
							}
							else if (tweenAction == TweenAction.CANVAS_MOVE_Y)
							{
								Vector3 current = tween.rectTransform.anchoredPosition3D;
								tween.rectTransform.anchoredPosition3D = new Vector3(current.x, val, current.z);
							}
							else if (tweenAction == TweenAction.CANVAS_MOVE_Z)
							{
								Vector3 current = tween.rectTransform.anchoredPosition3D;
								tween.rectTransform.anchoredPosition3D = new Vector3(current.x, current.y, val);
							}
#endif

						}
						else if (tweenAction >= TweenAction.MOVE)
						{
							//

							if (tween.animationCurve != null)
							{
								newVect = tweenOnCurveVector(tween, ratioPassed);
							}
							else
							{
								if (tween.tweenType == LeanTweenType.linear)
								{
									newVect = new Vector3(tween.from.x + tween.diff.x * ratioPassed, tween.from.y + tween.diff.y * ratioPassed, tween.from.z + tween.diff.z * ratioPassed);
								}
								else if (tween.tweenType >= LeanTweenType.linear)
								{
									switch (tween.tweenType)
									{
										case LeanTweenType.easeOutQuad:
											newVect = new Vector3(easeOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeOutQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeOutQuadOpt(tween.from.z, tween.diff.z, ratioPassed)); break;
										case LeanTweenType.easeInQuad:
											newVect = new Vector3(easeInQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeInQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeInQuadOpt(tween.from.z, tween.diff.z, ratioPassed)); break;
										case LeanTweenType.easeInOutQuad:
											newVect = new Vector3(easeInOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeInOutQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeInOutQuadOpt(tween.from.z, tween.diff.z, ratioPassed)); break;
										case LeanTweenType.easeInCubic:
											newVect = new Vector3(easeInCubic(tween.from.x, tween.to.x, ratioPassed), easeInCubic(tween.from.y, tween.to.y, ratioPassed), easeInCubic(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeOutCubic:
											newVect = new Vector3(easeOutCubic(tween.from.x, tween.to.x, ratioPassed), easeOutCubic(tween.from.y, tween.to.y, ratioPassed), easeOutCubic(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInOutCubic:
											newVect = new Vector3(easeInOutCubic(tween.from.x, tween.to.x, ratioPassed), easeInOutCubic(tween.from.y, tween.to.y, ratioPassed), easeInOutCubic(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInQuart:
											newVect = new Vector3(easeInQuart(tween.from.x, tween.to.x, ratioPassed), easeInQuart(tween.from.y, tween.to.y, ratioPassed), easeInQuart(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeOutQuart:
											newVect = new Vector3(easeOutQuart(tween.from.x, tween.to.x, ratioPassed), easeOutQuart(tween.from.y, tween.to.y, ratioPassed), easeOutQuart(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInOutQuart:
											newVect = new Vector3(easeInOutQuart(tween.from.x, tween.to.x, ratioPassed), easeInOutQuart(tween.from.y, tween.to.y, ratioPassed), easeInOutQuart(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInQuint:
											newVect = new Vector3(easeInQuint(tween.from.x, tween.to.x, ratioPassed), easeInQuint(tween.from.y, tween.to.y, ratioPassed), easeInQuint(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeOutQuint:
											newVect = new Vector3(easeOutQuint(tween.from.x, tween.to.x, ratioPassed), easeOutQuint(tween.from.y, tween.to.y, ratioPassed), easeOutQuint(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInOutQuint:
											newVect = new Vector3(easeInOutQuint(tween.from.x, tween.to.x, ratioPassed), easeInOutQuint(tween.from.y, tween.to.y, ratioPassed), easeInOutQuint(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInSine:
											newVect = new Vector3(easeInSine(tween.from.x, tween.to.x, ratioPassed), easeInSine(tween.from.y, tween.to.y, ratioPassed), easeInSine(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeOutSine:
											newVect = new Vector3(easeOutSine(tween.from.x, tween.to.x, ratioPassed), easeOutSine(tween.from.y, tween.to.y, ratioPassed), easeOutSine(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInOutSine:
											newVect = new Vector3(easeInOutSine(tween.from.x, tween.to.x, ratioPassed), easeInOutSine(tween.from.y, tween.to.y, ratioPassed), easeInOutSine(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInExpo:
											newVect = new Vector3(easeInExpo(tween.from.x, tween.to.x, ratioPassed), easeInExpo(tween.from.y, tween.to.y, ratioPassed), easeInExpo(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeOutExpo:
											newVect = new Vector3(easeOutExpo(tween.from.x, tween.to.x, ratioPassed), easeOutExpo(tween.from.y, tween.to.y, ratioPassed), easeOutExpo(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInOutExpo:
											newVect = new Vector3(easeInOutExpo(tween.from.x, tween.to.x, ratioPassed), easeInOutExpo(tween.from.y, tween.to.y, ratioPassed), easeInOutExpo(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInCirc:
											newVect = new Vector3(easeInCirc(tween.from.x, tween.to.x, ratioPassed), easeInCirc(tween.from.y, tween.to.y, ratioPassed), easeInCirc(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeOutCirc:
											newVect = new Vector3(easeOutCirc(tween.from.x, tween.to.x, ratioPassed), easeOutCirc(tween.from.y, tween.to.y, ratioPassed), easeOutCirc(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInOutCirc:
											newVect = new Vector3(easeInOutCirc(tween.from.x, tween.to.x, ratioPassed), easeInOutCirc(tween.from.y, tween.to.y, ratioPassed), easeInOutCirc(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInBounce:
											newVect = new Vector3(easeInBounce(tween.from.x, tween.to.x, ratioPassed), easeInBounce(tween.from.y, tween.to.y, ratioPassed), easeInBounce(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeOutBounce:
											newVect = new Vector3(easeOutBounce(tween.from.x, tween.to.x, ratioPassed), easeOutBounce(tween.from.y, tween.to.y, ratioPassed), easeOutBounce(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInOutBounce:
											newVect = new Vector3(easeInOutBounce(tween.from.x, tween.to.x, ratioPassed), easeInOutBounce(tween.from.y, tween.to.y, ratioPassed), easeInOutBounce(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInBack:
											newVect = new Vector3(easeInBack(tween.from.x, tween.to.x, ratioPassed), easeInBack(tween.from.y, tween.to.y, ratioPassed), easeInBack(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeOutBack:
											newVect = new Vector3(easeOutBack(tween.from.x, tween.to.x, ratioPassed, tween.overshoot), easeOutBack(tween.from.y, tween.to.y, ratioPassed, tween.overshoot), easeOutBack(tween.from.z, tween.to.z, ratioPassed, tween.overshoot)); break;
										case LeanTweenType.easeInOutBack:
											newVect = new Vector3(easeInOutBack(tween.from.x, tween.to.x, ratioPassed, tween.overshoot), easeInOutBack(tween.from.y, tween.to.y, ratioPassed, tween.overshoot), easeInOutBack(tween.from.z, tween.to.z, ratioPassed, tween.overshoot)); break;
										case LeanTweenType.easeInElastic:
											newVect = new Vector3(easeInElastic(tween.from.x, tween.to.x, ratioPassed, tween.overshoot, tween.period), easeInElastic(tween.from.y, tween.to.y, ratioPassed, tween.overshoot, tween.period), easeInElastic(tween.from.z, tween.to.z, ratioPassed, tween.overshoot, tween.period)); break;
										case LeanTweenType.easeOutElastic:
											newVect = new Vector3(easeOutElastic(tween.from.x, tween.to.x, ratioPassed, tween.overshoot, tween.period), easeOutElastic(tween.from.y, tween.to.y, ratioPassed, tween.overshoot, tween.period), easeOutElastic(tween.from.z, tween.to.z, ratioPassed, tween.overshoot, tween.period)); break;
										case LeanTweenType.easeInOutElastic:
											newVect = new Vector3(easeInOutElastic(tween.from.x, tween.to.x, ratioPassed, tween.overshoot, tween.period), easeInOutElastic(tween.from.y, tween.to.y, ratioPassed, tween.overshoot, tween.period), easeInOutElastic(tween.from.z, tween.to.z, ratioPassed, tween.overshoot, tween.period)); break;
										case LeanTweenType.punch:
										case LeanTweenType.easeShake:
											if (tween.tweenType == LeanTweenType.punch)
											{
												tween.animationCurve = LeanTween.punch;
											}
											else if (tween.tweenType == LeanTweenType.easeShake)
											{
												tween.animationCurve = LeanTween.shake;
											}
											tween.to = tween.from + tween.to;
											tween.diff = tween.to - tween.from;
											if (tweenAction == TweenAction.ROTATE || tweenAction == TweenAction.ROTATE_LOCAL)
											{
												tween.to = new Vector3(closestRot(tween.from.x, tween.to.x), closestRot(tween.from.y, tween.to.y), closestRot(tween.from.z, tween.to.z));
											}
											newVect = tweenOnCurveVector(tween, ratioPassed); break;
										case LeanTweenType.easeSpring:
											newVect = new Vector3(spring(tween.from.x, tween.to.x, ratioPassed), spring(tween.from.y, tween.to.y, ratioPassed), spring(tween.from.z, tween.to.z, ratioPassed)); break;

									}
								}
								else
								{
									newVect = new Vector3(tween.from.x + tween.diff.x * ratioPassed, tween.from.y + tween.diff.y * ratioPassed, tween.from.z + tween.diff.z * ratioPassed);
								}
							}

							if (tweenAction == TweenAction.MOVE)
							{
								trans.position = newVect;
							}
							else if (tweenAction == TweenAction.MOVE_LOCAL)
							{
								trans.localPosition = newVect;
							}
							else if (tweenAction == TweenAction.ROTATE)
							{
								/*if(tween.hasPhysics){
									trans.gameObject.rigidbody.MoveRotation(Quaternion.Euler( newVect ));
								}else{*/
								trans.eulerAngles = newVect;
								// }
							}
							else if (tweenAction == TweenAction.ROTATE_LOCAL)
							{
								trans.localEulerAngles = newVect;
							}
							else if (tweenAction == TweenAction.SCALE)
							{
								trans.localScale = newVect;
							}
							else if (tweenAction == TweenAction.GUI_MOVE)
							{
								tween.ltRect.rect = new Rect(newVect.x, newVect.y, tween.ltRect.rect.width, tween.ltRect.rect.height);
							}
							else if (tweenAction == TweenAction.GUI_MOVE_MARGIN)
							{
								tween.ltRect.margin = new Vector2(newVect.x, newVect.y);
							}
							else if (tweenAction == TweenAction.GUI_SCALE)
							{
								tween.ltRect.rect = new Rect(tween.ltRect.rect.x, tween.ltRect.rect.y, newVect.x, newVect.y);
							}
							else if (tweenAction == TweenAction.GUI_ALPHA)
							{
								tween.ltRect.alpha = newVect.x;
							}
							else if (tweenAction == TweenAction.GUI_ROTATE)
							{
								tween.ltRect.rotation = newVect.x;
							}
#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5
							else if (tweenAction == TweenAction.CANVAS_MOVE)
							{
								tween.rectTransform.anchoredPosition3D = newVect;
							}
							else if (tweenAction == TweenAction.CANVAS_SCALE)
							{
								tween.rectTransform.localScale = newVect;
							}
#endif
						}
						// Debug.Log("tween.delay:"+tween.delay + " tween.passed:"+tween.passed + " tweenAction:"+tweenAction + " to:"+newVect+" axis:"+tween.axis);

						if (dt != 0f && tween.hasUpdateCallback)
						{
							if (tween.onUpdateFloat != null)
							{
								tween.onUpdateFloat(val);
							}
							if (tween.onUpdateFloatRatio != null)
							{
								tween.onUpdateFloatRatio(val, ratioPassed);
							}
							else if (tween.onUpdateFloatObject != null)
							{
								tween.onUpdateFloatObject(val, tween.onUpdateParam);
							}
							else if (tween.onUpdateVector3Object != null)
							{
								tween.onUpdateVector3Object(newVect, tween.onUpdateParam);
							}
							else if (tween.onUpdateVector3 != null)
							{
								tween.onUpdateVector3(newVect);
							}
							else if (tween.onUpdateVector2 != null)
							{
								tween.onUpdateVector2(new Vector2(newVect.x, newVect.y));
							}
						}
#if LEANTWEEN_1
					else if(tween.optional!=null){ // LeanTween 1.x legacy stuff
						var onUpdate = tween.optional["onUpdate"];
						if(onUpdate!=null){
							Hashtable updateParam = (Hashtable)tween.optional["onUpdateParam"];
							if((TweenAction)tweenAction==TweenAction.VALUE3){
								if(onUpdate.GetType() == typeof(string)){
									string onUpdateS = onUpdate as string;
									customTarget = tween.optional["onUpdateTarget"]!=null ? tween.optional["onUpdateTarget"] as GameObject : trans.gameObject;
									customTarget.BroadcastMessage( onUpdateS, newVect );
								}else if(onUpdate.GetType() == typeof(System.Action<Vector3, Hashtable>)){
									System.Action<Vector3, Hashtable> onUpdateA = (System.Action<Vector3, Hashtable>)onUpdate;
									onUpdateA(newVect, updateParam);
								}else{
									System.Action<Vector3> onUpdateA = (System.Action<Vector3>)onUpdate;
									onUpdateA(newVect);
								}
							}else{
								if(onUpdate.GetType() == typeof(string)){
									string onUpdateS = onUpdate as string;
									if (tween.optional["onUpdateTarget"]!=null){
										customTarget = tween.optional["onUpdateTarget"] as GameObject;
										customTarget.BroadcastMessage( onUpdateS, val );
									}else{
										trans.gameObject.BroadcastMessage( onUpdateS, val );
									}
								}else if(onUpdate.GetType() == typeof(System.Action<float, Hashtable>)){
									System.Action<float, Hashtable> onUpdateA = (System.Action<float, Hashtable>)onUpdate;
									onUpdateA(val, updateParam);
								}else if(onUpdate.GetType() == typeof(System.Action<Vector3>)){
									System.Action<Vector3> onUpdateA = (System.Action<Vector3>)onUpdate;
									onUpdateA( newVect );
								}else{
									System.Action<float> onUpdateA = (System.Action<float>)onUpdate;
									onUpdateA(val);
								}
							}
						}
					}
#endif
					}

					if (isTweenFinished)
					{
						if (tween.loopType == LeanTweenType.once || tween.loopCount == 1)
						{
							tweensFinished[finishedCnt] = i;
							finishedCnt++;

							//Debug.Log("finished tween:"+i+" tween:"+tween);
							if (tweenAction == TweenAction.GUI_ROTATE)
								tween.ltRect.rotateFinished = true;

							if (tweenAction == TweenAction.DELAYED_SOUND)
							{
								AudioSource.PlayClipAtPoint((AudioClip)tween.onCompleteParam, tween.to, tween.from.x);
							}
						}
						else
						{
							if ((tween.loopCount < 0 && tween.type == TweenAction.CALLBACK) || tween.onCompleteOnRepeat)
							{
								if (tweenAction == TweenAction.DELAYED_SOUND)
								{
									AudioSource.PlayClipAtPoint((AudioClip)tween.onCompleteParam, tween.to, tween.from.x);
								}
								if (tween.onComplete != null)
								{
									tween.onComplete();
								}
								else if (tween.onCompleteObject != null)
								{
									tween.onCompleteObject(tween.onCompleteParam);
								}
							}
							if (tween.loopCount >= 1)
							{
								tween.loopCount--;
							}
							// Debug.Log("tween.loopType:"+tween.loopType+" tween.loopCount:"+tween.loopCount+" passed:"+tween.passed);
							if (tween.loopType == LeanTweenType.pingPong)
							{
								tween.direction = 0.0f - (tween.direction);
							}
							else
							{
								tween.passed = Mathf.Epsilon;
							}
						}
					}
					else if (tween.delay <= 0f)
					{
						tween.passed += dt * tween.direction;
					}
					else
					{
						tween.delay -= dt;
						// Debug.Log("dt:"+dt+" tween:"+i+" tween:"+tween);
						if (tween.delay < 0f)
						{
							tween.passed = 0.0f;//-tween.delay
							tween.delay = 0.0f;
						}
					}
				}
			}

			// Debug.Log("maxTweenReached:"+maxTweenReached);
			tweenMaxSearch = maxTweenReached;
			frameRendered = Time.frameCount;

			for (int i = 0; i < finishedCnt; i++)
			{
				j = tweensFinished[i];
				tween = tweens[j];

				// logError("removing tween:"+tween);
				if (tween.onComplete != null)
				{
					System.Action onComplete = tween.onComplete;
					//logError("removing tween for j:"+j+" tween:"+tween);
					removeTween(j);
					//tween.cleanup();
					onComplete();

				}
				else if (tween.onCompleteObject != null)
				{
					System.Action<object> onCompleteObject = tween.onCompleteObject;
					object onCompleteParam = tween.onCompleteParam;
					removeTween(j);
					//tween.cleanup();
					onCompleteObject(onCompleteParam);
				}
#if LEANTWEEN_1
			else if(tween.optional!=null){
				System.Action callback=null;
				System.Action<object> callbackWithParam = null;
				string callbackS=string.Empty;
				object callbackParam=null;
				Hashtable optional = tween.optional;
				if(tween.optional!=null && tween.trans){
					if(tween.optional["onComplete"]!=null){
						callbackParam = tween.optional["onCompleteParam"];
						if(tween.optional["onComplete"].GetType()==typeof(string)){
							callbackS = tween.optional["onComplete"] as string;
						}else{
							if(callbackParam!=null){
								callbackWithParam = (System.Action<object>)tween.optional["onComplete"];
							}else{
								callback = (System.Action)tween.optional["onComplete"];	
								if(callback==null)
									Debug.LogWarning("callback was not converted");
							}
						}
					}
				}
				removeTween(j);
				if(callbackWithParam!=null){
					callbackWithParam( callbackParam );
				}else if(callback!=null){
					callback();
				}else if(callbackS!=string.Empty){
					if (optional["onCompleteTarget"]!=null){
						customTarget = optional["onCompleteTarget"] as GameObject;
						if(callbackParam!=null) customTarget.BroadcastMessage ( callbackS, callbackParam );
						else customTarget.BroadcastMessage( callbackS );
					}else{
						if(callbackParam!=null) trans.gameObject.BroadcastMessage ( callbackS, callbackParam );
						else trans.gameObject.BroadcastMessage( callbackS );
					}
				}
				
			}
#endif
				else
				{
					removeTween(j);
					//tween.cleanup();
				}
			}

		}
	}
示例#47
0
 public LTDescr setGUIMoveMargin()
 {
     this.type = TweenAction.GUI_MOVE_MARGIN;
     this.initInternal = ()=>{ this.from = new Vector2(this._optional.ltRect.margin.x, this._optional.ltRect.margin.y); };
     this.easeInternal = ()=>{ Vector3 v = easeMethod(); this._optional.ltRect.margin = new Vector2(v.x, v.y); };
     return this;
 }
示例#48
0
    private static LTDescr pushNewTween( GameObject gameObject, Vector3 to, float time, TweenAction tweenAction, LTDescr tween )
    {
        init(maxTweens);
        if(gameObject==null)
        return null;
        tween.trans = gameObject.transform;
        tween.to = to;
        tween.time = time;
        tween.type = tweenAction;
        //tween.hasPhysics = gameObject.rigidbody!=null;

        return tween;
    }
示例#49
0
 public LTDescr setGUIScale()
 {
     this.type = TweenAction.GUI_SCALE;
     this.initInternal = ()=>{ this.from = new Vector3(this._optional.ltRect.rect.width, this._optional.ltRect.rect.height, 0); };
     this.easeInternal = ()=>{ Vector3 v = easeMethod(); this._optional.ltRect.rect = new Rect( this._optional.ltRect.rect.x, this._optional.ltRect.rect.y, v.x, v.y); };
     return this;
 }
示例#50
0
 public LTDescr setCanvasAlpha()
 {
     this.type = TweenAction.CANVAS_ALPHA;
     this.initInternal = ()=>{
         this.uiImage = trans.gameObject.GetComponent<UnityEngine.UI.Image>();
         this.fromInternal.x = this.uiImage != null ? this.uiImage.color.a : 1f;
     };
     this.easeInternal = ()=>{
         newVect = easeMethod();
         val = newVect.x;
         if(this.uiImage!=null){
             Color c = this.uiImage.color; c.a = val; this.uiImage.color = c;
         }
         if(this.useRecursion){
             alphaRecursive( this.rectTransform, val, 0 );
             textAlphaRecursive( this.rectTransform, val);
         }
     };
     return this;
 }
示例#51
0
 public LTDescr setMoveCurved()
 {
     this.type = TweenAction.MOVE_CURVED;
     this.initInternal = this.initFromInternal;
     this.easeInternal = ()=>{
         newVect = easeMethod();
         val = newVect.x;
         if(this._optional.path.orientToPath){
             if(this._optional.path.orientToPath2d){
                 this._optional.path.place2d( trans, val );
             }else{
                 this._optional.path.place( trans, val );
             }
         }else{
             trans.position = this._optional.path.point( val );
         }
     };
     return this;
 }
示例#52
0
 public void SelectScaleTween()
 {
     SelectedTweenAction = new ScaleTweenAction();
 }
示例#53
0
        public override void OnInspectorGUI()
        {
            GUI.DrawTexture(new Rect(16, EditorGUILayout.GetControlRect().y - 16, 16, 16), LTEditor.editorIcon());

            LeanTweenVisual tween = target as LeanTweenVisual;

            EditorGUI.BeginChangeCheck();
            float   overallDelay = 0;
            bool    clicked, deleted;
            Vector3 vec;

            clicked = false;

            tween.playOnStart = EditorGUILayout.Toggle(new GUIContent("Play on Start", "Tweens won't start automatically, you can start them via code with .start()"), tween.playOnStart, GUILayout.Width(100));
            EditorGUILayout.BeginHorizontal();

            tween.restartOnEnable = EditorGUILayout.Toggle(new GUIContent("Restart on enable", "When you enable the gameobject these set of tweens will start again"), tween.restartOnEnable);
            tween.repeat          = EditorGUILayout.Toggle(new GUIContent("Repeat All", "Repeat the whole set of tween groups once they finish"), tween.repeat);
            EditorGUILayout.EndHorizontal();
            if (tween.repeat)
            {
                tween.repeatDelay = EditorGUILayout.FloatField("All Delay", tween.repeatDelay);
                tween.repeatCount = EditorGUILayout.IntField("All Repeat Count", tween.repeatCount);
            }

            float addedGroupDelay = 0f;

            foreach (LeanTweenGroup group in tween.groupList)
            {
                EditorGUILayout.Space();

                GUI.color = LTEditor.shared.colorGroupName;
                EditorGUILayout.BeginHorizontal();

                group.foldout = EditorGUILayout.Foldout(group.foldout, "", LTEditor.shared.styleGroupFoldout);
                clicked       = GUILayout.Button("Group: " + group.name + " " + (group.startTime) + "s - " + (group.endTime) + "s", LTEditor.shared.styleGroupButton);
                GUI.color     = LTEditor.shared.colorDelete;
                deleted       = GUILayout.Button("Delete", LTEditor.shared.styleDeleteGroupButton);
                EditorGUILayout.EndHorizontal();
                GUI.color = Color.white;

                if (clicked)
                {
                    group.foldout = !group.foldout;
                }
                if (deleted)
                {
                    Undo.RecordObject(tween, "Removing group item");
                    tween.groupList.Remove(group);
                    break;
                }

                float addedTweenDelay = 0f;
                if (group.foldout)
                {
                    group.name = EditorGUILayout.TextField("Group Name", group.name);
                    EditorGUILayout.BeginHorizontal();
                    group.repeat = EditorGUILayout.Toggle("Group Repeat", group.repeat);
                    group.delay  = EditorGUILayout.FloatField("Group Delay", group.delay);
                    EditorGUILayout.EndHorizontal();

                    group.gameObject = EditorGUILayout.ObjectField("Group GameObject", group.gameObject, typeof(GameObject), true) as GameObject;
                    if (group.gameObject == null)                   // Should default to the current object
                    {
                        group.gameObject = tween.gameObject;
                    }
                    if (group.repeat)
                    {
                        group.repeatCount = EditorGUILayout.IntField("Group Repeat Count", group.repeatCount);
                    }

                    int i = 0;
                    foreach (LeanTweenItem item in group.itemList)
                    {
                        TweenAction a = (TweenAction)item.action;

                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Space(15);

                        item.foldout = EditorGUILayout.Foldout(item.foldout, "Tween ");
                        GUI.color    = LTEditor.shared.colorTweenName;

                        int actionIndex = EditorGUILayout.Popup(LTVisualShared.actionIndex(item), LTVisualShared.methodLabels);

                        LTVisualShared.setActionIndex(item, actionIndex);

                        // clicked = GUILayout.Button(""+a + " " + ( group.delay + item.delay) + "s - " + ( group.delay + item.delay + item.duration) + "s");
                        GUI.color = LTEditor.shared.colorDelete;
                        deleted   = GUILayout.Button("Delete", LTEditor.shared.styleDeleteButton);
                        EditorGUILayout.EndHorizontal();
                        GUI.color = Color.white;


                        if (clicked)
                        {
                            item.foldout = !item.foldout;
                        }
                        if (deleted)
                        {
                            Undo.RecordObject(tween, "Removing tween item");
                            group.itemList.Remove(item);

                            break;
                        }

                        if (item.foldout)
                        {
                            a = item.action;
                            bool tweenTypeChanged = (int)item.action != item.actionLast;
                            if (tweenTypeChanged && item.actionLast >= 0)
                            {
                                // Setup with the helpful default values
                                // Debug.Log("Setting up to default values a:"+a);

                                /*item.to = Vector3.zero;
                                 * if((a>=TweenAction.MOVE_X && a<=TweenAction.MOVE_LOCAL_Z) || a==TweenAction.MOVE || a==TweenAction.MOVE_LOCAL)
                                 *      item.to = item.from = tween.gameObject.transform.position;
                                 * else if((a>=TweenAction.SCALE_X && a<=TweenAction.SCALE_Z) || a==TweenAction.SCALE)
                                 *      item.to = item.from = tween.gameObject.transform.localScale;
                                 #if !UNITY_4_3 && !UNITY_4_5
                                 * else if(a==TweenAction.CANVAS_MOVE)
                                 *      item.to = item.from = tween.gameObject.GetComponent<RectTransform>().anchoredPosition;
                                 * else if(a==TweenAction.CANVAS_SCALE)
                                 *      item.to = item.from = tween.gameObject.GetComponent<RectTransform>().localScale;
                                 #endif
                                 */
                            }
                            item.actionLast = (int)item.action;
                            // Debug.Log("a:"+a);

                            item.gameObject = EditorGUILayout.ObjectField("    GameObject", item.gameObject, typeof(GameObject), true, GUILayout.Width(250)) as GameObject;
                            if (item.gameObject == null)                           // Should default to the current object
                            {
                                item.gameObject = tween.gameObject;
                            }

                            // Path
                            bool isCurve = false;
                            if (a == TweenAction.MOVE_CURVED || a == TweenAction.MOVE_CURVED_LOCAL)
                            {
                                item.bezierPath = EditorGUILayout.ObjectField("    LeanTweenPath:", item.bezierPath, typeof(LeanTweenPath), true) as LeanTweenPath;

                                EditorGUILayout.BeginHorizontal();
                                change(ref item.orientToPath, EditorGUILayout.Toggle("    Orient to Path", item.orientToPath), tween, "Orient to path");
//								if(orientToPath!=item.orientToPath){
//									Undo.RecordObject(tween,"Orient to path");
//									item.orientToPath = orientToPath;
//								}
                                isCurve = true;

                                item.isPath2d = EditorGUILayout.Toggle("    2D Path", item.isPath2d);
                                EditorGUILayout.EndHorizontal();
                            }
                            else if (a == TweenAction.MOVE_SPLINE || a == TweenAction.MOVE_SPLINE_LOCAL)
                            {
                                item.splinePath   = EditorGUILayout.ObjectField("    LeanTweenPath:", item.splinePath, typeof(LeanTweenPath), true) as LeanTweenPath;
                                item.orientToPath = EditorGUILayout.Toggle("    Orient to Path", item.orientToPath);
                                isCurve           = true;
                            }

                            if (isCurve == false)
                            {
                                bool isVector = a == TweenAction.MOVE || a == TweenAction.MOVE_LOCAL || a == TweenAction.CANVAS_MOVE || a == TweenAction.ROTATE || a == TweenAction.ROTATE_LOCAL || a == TweenAction.SCALE || a == TweenAction.CANVAS_SCALE || a == TweenAction.CANVAS_SIZEDELTA || a == TweenAction.DELAYED_SOUND;
                                bool isColor  = a >= TweenAction.COLOR && a < TweenAction.CALLBACK;
                                bool isPlay   = a == TweenAction.CANVAS_PLAYSPRITE;
                                bool usesFrom = !isColor && !isPlay;

                                // From Values
                                EditorGUILayout.BeginHorizontal();
                                if (usesFrom)                                 // Not a Color tween
                                {
                                    EditorGUILayout.LabelField(new GUIContent("    From", "Specify where the tween starts from, otherwise it will start from it's current value"), GUILayout.Width(50));
                                    LeanTweenBetween between = EditorGUILayout.Toggle("", item.between == LeanTweenBetween.FromTo, GUILayout.Width(30)) ? LeanTweenBetween.FromTo : LeanTweenBetween.To;
                                    if (between != item.between)
                                    {
                                        Undo.RecordObject(tween, "Changing to from/to");
                                        item.between = between;
                                    }
                                }
                                if (item.between == LeanTweenBetween.FromTo)
                                {
                                    if (isVector)
                                    {
//										item.from = EditorGUILayout.Vector3Field("", item.from);
                                        change(ref item.from, EditorGUILayout.Vector3Field("", item.from), tween, "Changing from");
                                    }
                                    else if (isColor)
                                    {
                                    }
                                    else
                                    {
                                        vec   = Vector3.zero;
                                        vec.x = EditorGUILayout.FloatField("From", item.from.x);
                                        if (vec.x != item.from.x)
                                        {
                                            Undo.RecordObject(tween, "Setting new from value");
                                            item.from = vec;
                                        }
                                    }
                                }
                                EditorGUILayout.EndHorizontal();

                                // To Values
                                EditorGUILayout.BeginHorizontal();
                                if (isVector)
                                {
                                    EditorGUILayout.LabelField("    To", GUILayout.Width(85));
                                    change(ref item.to, EditorGUILayout.Vector3Field("", item.to), tween, "Changing vector3 to");
                                }
                                else if (isColor)
                                {
                                    EditorGUILayout.LabelField("    To", GUILayout.Width(85));
                                    change(ref item.colorTo, EditorGUILayout.ColorField("", item.colorTo), tween, "Change color to");
                                }
                                else if (isPlay)
                                {
                                    GUILayout.Space(24);
                                    item.spritesMaximized = EditorGUILayout.Foldout(item.spritesMaximized, "Sprites");
                                    if (item.spritesMaximized)
                                    {
                                        EditorGUILayout.LabelField("Add", GUILayout.Width(35));
                                        UnityEngine.Sprite sprite = EditorGUILayout.ObjectField("", null, typeof(UnityEngine.Sprite), true, GUILayout.Width(150)) as UnityEngine.Sprite;
                                        if (sprite != null)
                                        {
                                            Undo.RecordObject(tween, "Adding a sprite");
                                            item.sprites = add(item.sprites, sprite);
                                        }
                                        EditorGUILayout.Separator();
                                        EditorGUILayout.Separator();
                                        EditorGUILayout.Separator();
                                    }
                                }
                                else
                                {
                                    vec = Vector3.zero;
                                    EditorGUILayout.LabelField("    To", GUILayout.Width(85));
                                    float setToX = EditorGUILayout.FloatField("", item.to.x);
                                    if (setToX != vec.x)
                                    {
                                        Undo.RecordObject(tween, "Setting x to");
                                        vec.x   = setToX;
                                        item.to = vec;
                                    }
                                }
                                EditorGUILayout.EndHorizontal();

                                // Sprite List
                                if (isPlay && item.spritesMaximized)
                                {
                                    for (int j = 0; j < item.sprites.Length; j++)
                                    {
                                        EditorGUILayout.BeginHorizontal();
                                        EditorGUILayout.LabelField("        sprite" + j, GUILayout.Width(85));
                                        item.sprites[j] = EditorGUILayout.ObjectField("", item.sprites[j], typeof(UnityEngine.Sprite), true) as UnityEngine.Sprite;
                                        GUI.color       = LTEditor.shared.colorDelete;
                                        deleted         = GUILayout.Button("Delete", LTEditor.shared.styleDeleteButton);
                                        GUI.color       = Color.white;
                                        EditorGUILayout.EndHorizontal();

                                        if (deleted)
                                        {
                                            Undo.RecordObject(tween, "Removing sprite");
                                            item.sprites = remove(item.sprites, j);
                                            break;
                                        }
                                    }
                                }

                                if (a == TweenAction.ROTATE_AROUND || a == TweenAction.ROTATE_AROUND_LOCAL
                                                                #if !UNITY_4_3 && !UNITY_4_5
                                    || a == TweenAction.CANVAS_ROTATEAROUND || a == TweenAction.CANVAS_ROTATEAROUND_LOCAL
                                                                #endif
                                    )
                                {
                                    item.axis = ShowAxis("    Axis", item.axis);
                                }
                            }
                            EditorGUILayout.Space();

                            // Easing
                            if (a == TweenAction.DELAYED_SOUND)
                            {
                                change(ref item.audioClip, EditorGUILayout.ObjectField("    AudioClip:", item.audioClip, typeof(AudioClip), true) as AudioClip, tween, "set audio clip");
                            }
                            else
                            {
                                EditorGUILayout.BeginHorizontal();
                                EditorGUILayout.LabelField("    Easing", GUILayout.Width(80));

                                int easeIndex    = LTVisualShared.easeIndex(item);
                                int easeIndexNew = EditorGUILayout.Popup("", easeIndex, LTVisualShared.easeStrMapping, GUILayout.Width(128));
                                if (easeIndex != easeIndexNew)
                                {
                                    Undo.RecordObject(tween, "changing easing type");
                                    LTVisualShared.setEaseIndex(item, easeIndexNew);
                                }

                                EditorGUILayout.Separator();
                                EditorGUILayout.EndHorizontal();

                                if (item.ease == LeanTweenType.animationCurve)
                                {
                                    Undo.RecordObject(tween, "changing easing type anim curve");
                                    item.animationCurve = EditorGUILayout.CurveField("    Ease Curve", item.animationCurve);
                                }
                                EditorGUILayout.Space();
                            }
                            if (item.ease >= LeanTweenType.once && item.ease < LeanTweenType.animationCurve)
                            {
                                EditorGUILayout.LabelField(new GUIContent("   ERROR: You Specified a non-easing type", "Select a type with the value 'Ease' in front of it (or linear)"), EditorStyles.boldLabel);
                            }

                            // Speed

                            EditorGUILayout.BeginHorizontal();
                            change(ref item.useSpeed, EditorGUILayout.Toggle("    Use Speed", item.useSpeed), tween, "toggled use speed");
                            EditorGUILayout.EndHorizontal();

                            // Timing
                            if (i > 0)
                            {
                                change(ref item.alignWithPrevious, EditorGUILayout.Toggle(new GUIContent("    Align with Previous", "When you change the timing of a previous tween, this tween's timing will be adjusted to follow afterwards."), item.alignWithPrevious),
                                       tween, "toggle align with previous");
                            }
                            EditorGUILayout.BeginHorizontal();
                            if (i > 0 && item.alignWithPrevious)
                            {
                                change(ref item.delay, addedTweenDelay, tween, "change delay");
                                EditorGUILayout.LabelField("    Delay:   " + item.delay, GUILayout.Width(50));
                            }
                            else
                            {
                                EditorGUILayout.LabelField("    Delay", GUILayout.Width(50));
                                change(ref item.delay, EditorGUILayout.FloatField("", item.delay, GUILayout.Width(50)), tween, "change delay");
                            }

                            if (a == TweenAction.DELAYED_SOUND)
                            {
                                EditorGUILayout.LabelField("Volume", GUILayout.Width(50));
                                change(ref item.duration, EditorGUILayout.FloatField("", item.duration, GUILayout.Width(50)), tween, "change volume");
                            }
                            else if (a == TweenAction.CANVAS_PLAYSPRITE)
                            {
                                EditorGUILayout.LabelField("Frame Rate", GUILayout.Width(85));
                                change(ref item.frameRate, EditorGUILayout.FloatField("", item.frameRate, GUILayout.Width(50)), tween, "change volume");
                            }
                            else if (item.useSpeed)
                            {
                                EditorGUILayout.LabelField("Speed", GUILayout.Width(50));
                                change(ref item.speed, EditorGUILayout.FloatField("", item.speed, GUILayout.Width(50)), tween, "change speed");
                            }
                            else
                            {
                                EditorGUILayout.LabelField("Time", GUILayout.Width(50));
                                float newDuration = EditorGUILayout.FloatField("", item.duration, GUILayout.Width(50));
                                if (newDuration <= 0.0f)
                                {
                                    newDuration = 0.0001f;
                                }
                                change(ref item.duration, newDuration, tween, "change timing");
                            }
                            EditorGUILayout.Separator();
                            EditorGUILayout.EndHorizontal();



                            // Repeat
                            EditorGUILayout.Space();
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("    Loops", GUILayout.Width(50));
                            change(ref item.doesLoop, EditorGUILayout.Toggle("", item.doesLoop, GUILayout.Width(50)), tween, "toggled does loop");

                            if (item.doesLoop)
                            {
                                EditorGUILayout.LabelField(new GUIContent("Repeat", "-1 repeats infinitely"), GUILayout.Width(50));
                                change(ref item.loopCount, EditorGUILayout.IntField(new GUIContent("", ""), item.loopCount, GUILayout.Width(50)), tween, "changed loop count");
                                EditorGUILayout.LabelField(new GUIContent("    Wrap", "How the tween repeats\nclamp: restart from beginning\npingpong: goes back and forth"), GUILayout.Width(50));
                                int index = item.loopType == LeanTweenType.pingPong ? 1 : 0;
                                index = EditorGUILayout.Popup("", index, new string[] { "Clamp", "Ping Pong" }, GUILayout.Width(70));
                                LeanTweenType newLoopType = index == 0 ? LeanTweenType.clamp : LeanTweenType.pingPong;
                                if (newLoopType != item.loopType)
                                {
                                    Undo.RecordObject(tween, "change loop type");
                                    item.loopType = newLoopType;
                                }
                            }
                            EditorGUILayout.EndHorizontal();

                            addedTweenDelay = item.duration + item.delay;

                            EditorGUILayout.Separator();
                            EditorGUILayout.Separator();

                            i++;
                        }
                    }
                    if (ShowLeftButton("+ Tween", LTEditor.shared.colorAddTween, 15))
                    {
                        Undo.RecordObject(tween, "adding another tween");
                        LeanTweenItem newItem = new LeanTweenItem(addedTweenDelay);
                        newItem.alignWithPrevious = true;
                        group.itemList.Add(newItem);
                    }
                    addedGroupDelay += addedTweenDelay;

                    EditorGUILayout.Separator();
                }
                overallDelay += group.endTime;
            }

            if (ShowLeftButton("+ Group", LTEditor.shared.colorAddGroup))
            {
                Undo.RecordObject(tween, "adding another group");
                // Debug.Log("adding group with delay:"+addedGroupDelay);
                tween.groupList.Add(new LeanTweenGroup(addedGroupDelay));
            }


            EditorGUILayout.Separator();
            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("Generated C# Code", EditorStyles.boldLabel);
            if (Application.isPlaying == false)
            {
                scrollCodeViewPos = EditorGUILayout.BeginScrollView(scrollCodeViewPos, GUILayout.Height(150));

                EditorGUILayout.TextArea(tween.buildAllTweens(true), LTEditor.shared.styleCodeTextArea);

                EditorGUILayout.EndScrollView();
            }
            else
            {
                EditorGUILayout.LabelField("    Not available during runtime");
            }

            if (EditorGUI.EndChangeCheck())
            {
//				Debug.Log("Saving time:"+Time.time);
                //Undo.RecordObject(tween, "LeanTweenVisual change");
            }
        }
示例#54
0
 public LTDescr setScaleZ()
 {
     this.type = TweenAction.SCALE_Z;
     this.initInternal = ()=>{ this.fromInternal.x = trans.localScale.z; };
     this.easeInternal = ()=>{ trans.localScale=new Vector3( trans.localScale.x,trans.localScale.y,easeMethod().x); };
     return this;
 }
示例#55
0
    public static void update()
    {
        if(frameRendered != Time.frameCount){ // make sure update is only called once per frame
        init();

        dtEstimated = Time.realtimeSinceStartup - previousRealTime;
        if(dtEstimated>0.2f) // a catch put in, when at the start sometimes this number can grow unrealistically large
            dtEstimated = 0.2f;
        previousRealTime = Time.realtimeSinceStartup;
        dtActual = Time.deltaTime*Time.timeScale;
        // if(tweenMaxSearch>1500)
        // 	Debug.Log("tweenMaxSearch:"+tweenMaxSearch +" maxTweens:"+maxTweens);
        for( int i = 0; i < tweenMaxSearch && i < maxTweens; i++){

            //Debug.Log("tweens["+i+"].toggle:"+tweens[i].toggle);
            if(tweens[i].toggle){
                tween = tweens[i];
                trans = tween.trans;
                timeTotal = tween.time;
                tweenAction = tween.type;

                dt = dtActual;
                if( tween.useEstimatedTime ){
                    dt = dtEstimated;
                    timeTotal = tween.time;
                }else if( tween.useFrames ){
                    dt = 1;
                }else if(tween.direction==0f){
                    dt = 0f;
                }

                if(trans==null){
                    removeTween(i);
                    continue;
                }
                // Debug.Log("i:"+i+" tween:"+tween+" dt:"+dt);

                // Check for tween finished
                isTweenFinished = false;
                if(tween.delay<=0){
                    if((tween.passed + dt > timeTotal && tween.direction > 0.0f )){
                        isTweenFinished = true;
                        tween.passed = tween.time; // Set to the exact end time so that it can finish tween exactly on the end value
                    }else if(tween.direction<0.0f && tween.passed - dt < 0.0f){
                        isTweenFinished = true;
                        tween.passed = Mathf.Epsilon;
                    }
                }

                if(!tween.hasInitiliazed && ((tween.passed==0.0 && tween.delay==0.0) || tween.passed>0.0) ){
                    tween.hasInitiliazed = true;

                    // Set time based on current timeScale
                    if( !tween.useEstimatedTime ){
                        tween.time = tween.time*Time.timeScale;
                    }

                    // Initialize From Values
                    switch(tweenAction){
                        case TweenAction.MOVE:
                            tween.from = trans.position; break;
                        case TweenAction.MOVE_X:
                            tween.from.x = trans.position.x; break;
                        case TweenAction.MOVE_Y:
                            tween.from.x = trans.position.y; break;
                        case TweenAction.MOVE_Z:
                            tween.from.x = trans.position.z; break;
                        case TweenAction.MOVE_LOCAL_X:
                            tweens[i].from.x = trans.localPosition.x; break;
                        case TweenAction.MOVE_LOCAL_Y:
                            tweens[i].from.x = trans.localPosition.y; break;
                        case TweenAction.MOVE_LOCAL_Z:
                            tweens[i].from.x = trans.localPosition.z; break;
                        case TweenAction.SCALE_X:
                            tween.from.x = trans.localScale.x; break;
                        case TweenAction.SCALE_Y:
                            tween.from.x = trans.localScale.y; break;
                        case TweenAction.SCALE_Z:
                            tween.from.x = trans.localScale.z; break;
                        case TweenAction.ALPHA:
                            #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
                                tween.from.x = trans.gameObject.renderer.material.color.a;
                                break;
                            #else
                                SpriteRenderer ren = trans.gameObject.GetComponent<SpriteRenderer>();
                                if(ren!=null){
                                    tween.from.x = ren.color.a;
                                }else if(trans.gameObject.renderer!=null){
                                    tween.from.x = trans.gameObject.renderer.material.color.a;
                                }
                                break;
                            #endif
                        case TweenAction.MOVE_LOCAL:
                            tween.from = trans.localPosition; break;
                        case TweenAction.MOVE_CURVED:
                        case TweenAction.MOVE_CURVED_LOCAL:
                        case TweenAction.MOVE_SPLINE:
                        case TweenAction.MOVE_SPLINE_LOCAL:
                            tween.from.x = 0; break;
                        case TweenAction.ROTATE:
                            tween.from = trans.eulerAngles;
                            tween.to = new Vector3(LeanTween.closestRot( tween.from.x, tween.to.x), LeanTween.closestRot( tween.from.y, tween.to.y), LeanTween.closestRot( tween.from.z, tween.to.z));
                            break;
                        case TweenAction.ROTATE_X:
                            tween.from.x = trans.eulerAngles.x;
                            tween.to.x = LeanTween.closestRot( tween.from.x, tween.to.x);
                            break;
                        case TweenAction.ROTATE_Y:
                            tween.from.x = trans.eulerAngles.y;
                            tween.to.x = LeanTween.closestRot( tween.from.x, tween.to.x);
                            break;
                        case TweenAction.ROTATE_Z:
                            tween.from.x = trans.eulerAngles.z;
                            tween.to.x = LeanTween.closestRot( tween.from.x, tween.to.x);
                            break;
                        case TweenAction.ROTATE_AROUND:
                            tween.lastVal = 0.0f; // optional["last"]
                            tween.from.x = 0.0f;
                            tween.origRotation = trans.rotation; // optional["origRotation"
                            break;
                        case TweenAction.ROTATE_AROUND_LOCAL:
                            tween.lastVal = 0.0f; // optional["last"]
                            tween.from.x = 0.0f;
                            tween.origRotation = trans.localRotation; // optional["origRotation"
                            break;
                        case TweenAction.ROTATE_LOCAL:
                            tween.from = trans.localEulerAngles;
                            tween.to = new Vector3(LeanTween.closestRot( tween.from.x, tween.to.x), LeanTween.closestRot( tween.from.y, tween.to.y), LeanTween.closestRot( tween.from.z, tween.to.z));
                            break;
                        case TweenAction.SCALE:
                            tween.from = trans.localScale; break;
                        case TweenAction.GUI_MOVE:
                            tween.from = new Vector3(tween.ltRect.rect.x, tween.ltRect.rect.y, 0); break;
                        case TweenAction.GUI_MOVE_MARGIN:
                            tween.from = new Vector2(tween.ltRect.margin.x, tween.ltRect.margin.y); break;
                        case TweenAction.GUI_SCALE:
                            tween.from = new  Vector3(tween.ltRect.rect.width, tween.ltRect.rect.height, 0); break;
                        case TweenAction.GUI_ALPHA:
                            tween.from.x = tween.ltRect.alpha; break;
                        case TweenAction.GUI_ROTATE:
                            if(tween.ltRect.rotateEnabled==false){
                                tween.ltRect.rotateEnabled = true;
                                tween.ltRect.resetForRotation();
                            }

                            tween.from.x = tween.ltRect.rotation; break;
                        case TweenAction.ALPHA_VERTEX:
                            tween.from.x = trans.GetComponent<MeshFilter>().mesh.colors32[0].a;
                            break;
                        case TweenAction.CALLBACK_COLOR:
                            tween.diff = new Vector3(1.0f,0.0f,0.0f);
                            break;
                        case TweenAction.COLOR:
                            #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
                                if(trans.gameObject.renderer){
                                    Color col = trans.gameObject.renderer.material.color;
                                    tween.from = new Vector3(0.0f, col.a, 0.0f);
                                    tween.diff = new Vector3(1.0f,0.0f,0.0f);
                                    tween.axis = new Vector3( col.r, col.g, col.b );
                                }
                            #else
                                SpriteRenderer ren2 = trans.gameObject.GetComponent<SpriteRenderer>();
                                if(ren2!=null){
                                    tween.from = new Vector3(0.0f, ren2.color.a, 0.0f);
                                    tween.diff = new Vector3(1.0f,0.0f,0.0f);
                                    tween.axis = new Vector3( ren2.color.r, ren2.color.g, ren2.color.b );
                                }else if(trans.gameObject.renderer!=null){
                                    if(trans.gameObject.renderer){
                                        Color col = trans.gameObject.renderer.material.color;
                                        tween.from = new Vector3(0.0f, col.a, 0.0f);
                                        tween.diff = new Vector3(1.0f,0.0f,0.0f);
                                        tween.axis = new Vector3( col.r, col.g, col.b );
                                    }
                                }
                            #endif
                            break;
                    }
                    if(tweenAction!=TweenAction.CALLBACK_COLOR && tweenAction!=TweenAction.COLOR)
                        tween.diff = tween.to - tween.from;
                }
                if(tween.delay<=0){
                    // Move Values
                    if(timeTotal<=0f){
                        //Debug.LogError("time total is zero Time.timeScale:"+Time.timeScale+" useEstimatedTime:"+tween.useEstimatedTime);
                        ratioPassed = 0f;
                    }else{
                        ratioPassed = tween.passed / timeTotal;
                    }

                    if(ratioPassed>1.0f){
                        ratioPassed = 1.0f;
                    }else if(ratioPassed<0f){
                        ratioPassed = 0f;
                    }
                    // Debug.Log("action:"+tweenAction+" ratioPassed:"+ratioPassed + " timeTotal:" + timeTotal + " tween.passed:"+ tween.passed +" dt:"+dt);

                    if(tweenAction>=TweenAction.MOVE_X && tweenAction<=TweenAction.CALLBACK){
                        if(tween.animationCurve!=null){
                            val = tweenOnCurve(tween, ratioPassed);
                        }else {
                            switch( tween.tweenType ){
                                case LeanTweenType.linear:
                                    val = tween.from.x + tween.diff.x * ratioPassed; break;
                                case LeanTweenType.easeOutQuad:
                                    val = easeOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed); break;
                                case LeanTweenType.easeInQuad:
                                    val = easeInQuadOpt(tween.from.x, tween.diff.x, ratioPassed); break;
                                case LeanTweenType.easeInOutQuad:
                                    val = easeInOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed); break;
                                case LeanTweenType.easeInCubic:
                                    val = easeInCubic(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutCubic:
                                    val = easeOutCubic(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutCubic:
                                    val = easeInOutCubic(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInQuart:
                                    val = easeInQuart(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutQuart:
                                    val = easeOutQuart(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutQuart:
                                    val = easeInOutQuart(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInQuint:
                                    val = easeInQuint(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutQuint:
                                    val = easeOutQuint(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutQuint:
                                    val = easeInOutQuint(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInSine:
                                    val = easeInSine(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutSine:
                                    val = easeOutSine(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutSine:
                                    val = easeInOutSine(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInExpo:
                                    val = easeInExpo(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutExpo:
                                    val = easeOutExpo(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutExpo:
                                    val = easeInOutExpo(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInCirc:
                                    val = easeInCirc(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutCirc:
                                    val = easeOutCirc(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutCirc:
                                    val = easeInOutCirc(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInBounce:
                                    val = easeInBounce(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutBounce:
                                    val = easeOutBounce(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutBounce:
                                    val = easeInOutBounce(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInBack:
                                    val = easeInBack(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutBack:
                                    val = easeOutBack(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutBack:
                                    val = easeInOutElastic(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInElastic:
                                    val = easeInElastic(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutElastic:
                                    val = easeOutElastic(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutElastic:
                                    val = easeInOutElastic(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.punch:
                                case LeanTweenType.easeShake:
                                    if(tween.tweenType==LeanTweenType.punch){
                                        tween.animationCurve = LeanTween.punch;
                                    }else if(tween.tweenType==LeanTweenType.easeShake){
                                        tween.animationCurve = LeanTween.shake;
                                    }
                                    tween.to.x = tween.from.x + tween.to.x;
                                    tween.diff.x = tween.to.x - tween.from.x;
                                    val = tweenOnCurve(tween, ratioPassed); break;
                                case LeanTweenType.easeSpring:
                                    val = spring(tween.from.x, tween.to.x, ratioPassed); break;
                                default:
                                    {
                                        val = tween.from.x + tween.diff.x * ratioPassed; break;
                                    }
                            }

                        }

                        //Debug.Log("from:"+from+" to:"+to+" val:"+val+" ratioPassed:"+ratioPassed);
                        if(tweenAction==TweenAction.MOVE_X){
                            trans.position=new Vector3( val,trans.position.y,trans.position.z);
                        }else if(tweenAction==TweenAction.MOVE_Y){
                            trans.position =new Vector3( trans.position.x,val,trans.position.z);
                        }else if(tweenAction==TweenAction.MOVE_Z){
                            trans.position=new Vector3( trans.position.x,trans.position.y,val);
                        }if(tweenAction==TweenAction.MOVE_LOCAL_X){
                            trans.localPosition=new Vector3( val,trans.localPosition.y,trans.localPosition.z);
                        }else if(tweenAction==TweenAction.MOVE_LOCAL_Y){
                            trans.localPosition=new Vector3( trans.localPosition.x,val,trans.localPosition.z);
                        }else if(tweenAction==TweenAction.MOVE_LOCAL_Z){
                            trans.localPosition=new Vector3( trans.localPosition.x,trans.localPosition.y,val);
                        }else if(tweenAction==TweenAction.MOVE_CURVED){
                            if(tween.path.orientToPath){
                                tween.path.place( trans, val );
                            }else{
                                trans.position = tween.path.point( val );
                            }
                            // Debug.Log("val:"+val+" trans.position:"+trans.position + " 0:"+ tween.curves[0] +" 1:"+tween.curves[1] +" 2:"+tween.curves[2] +" 3:"+tween.curves[3]);
                        }else if((TweenAction)tweenAction==TweenAction.MOVE_CURVED_LOCAL){
                            if(tween.path.orientToPath){
                                tween.path.placeLocal( trans, val );
                            }else{
                                trans.localPosition = tween.path.point( val );
                            }
                            // Debug.Log("val:"+val+" trans.position:"+trans.position);
                        }else if((TweenAction)tweenAction==TweenAction.MOVE_SPLINE){
                            if(tween.spline.orientToPath){
                                tween.spline.place( trans, val );
                            }else{
                                trans.position = tween.spline.point( val );
                            }
                        }else if((TweenAction)tweenAction==TweenAction.MOVE_SPLINE_LOCAL){
                            if(tween.spline.orientToPath){
                                tween.spline.placeLocal( trans, val );
                            }else{
                                trans.localPosition = tween.spline.point( val );
                            }
                        }else if(tweenAction==TweenAction.SCALE_X){
                            trans.localScale=new Vector3(val, trans.localScale.y,trans.localScale.z);
                        }else if(tweenAction==TweenAction.SCALE_Y){
                            trans.localScale=new Vector3( trans.localScale.x,val,trans.localScale.z);
                        }else if(tweenAction==TweenAction.SCALE_Z){
                            trans.localScale=new Vector3(trans.localScale.x,trans.localScale.y,val);
                        }else if(tweenAction==TweenAction.ROTATE_X){
                            trans.eulerAngles=new Vector3(val, trans.eulerAngles.y,trans.eulerAngles.z);
                        }else if(tweenAction==TweenAction.ROTATE_Y){
                            trans.eulerAngles=new Vector3(trans.eulerAngles.x,val,trans.eulerAngles.z);
                        }else if(tweenAction==TweenAction.ROTATE_Z){
                            trans.eulerAngles=new Vector3(trans.eulerAngles.x,trans.eulerAngles.y,val);
                        }else if(tweenAction==TweenAction.ROTATE_AROUND){

                            float move = val -  tween.lastVal;
                            // Debug.Log("move:"+move+" val:"+val + " timeTotal:"+timeTotal + " from:"+tween.from+ " diff:"+tween.diff);
                            if(isTweenFinished){
                                if(tween.direction>0){
                                    trans.rotation = tween.origRotation;
                                    trans.RotateAround((Vector3)trans.TransformPoint( tween.point ), tween.axis, tween.to.x);
                                }else{
                                    trans.rotation = tween.origRotation;
                                }
                            }else{
                                /*trans.rotation = tween.origRotation;
                                trans.RotateAround((Vector3)trans.TransformPoint( tween.point ), tween.axis, val);
                                tween.lastVal = val;*/

                                trans.RotateAround((Vector3)trans.TransformPoint( tween.point ), tween.axis, move);
                                tween.lastVal = val;

                                //trans.rotation =  * Quaternion.AngleAxis(val, tween.axis);
                            }

                        }else if(tweenAction==TweenAction.ROTATE_AROUND_LOCAL){
                            float move = val -  tween.lastVal;
                            if(isTweenFinished){
                                if(tween.direction>0){
                                    trans.localRotation = tween.origRotation;
                                trans.RotateAround((Vector3)trans.TransformPoint( tween.point ), trans.TransformDirection(tween.axis), tween.to.x);
                                }else{
                                    trans.localRotation = tween.origRotation;
                                }
                            }else{
                                trans.RotateAround((Vector3)trans.TransformPoint( tween.point ), trans.TransformDirection(tween.axis), move);
                                tween.lastVal = val;
                            }
                        }else if(tweenAction==TweenAction.ALPHA){
                            #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2

                            foreach(Material mat in trans.gameObject.renderer.materials){
                                mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val);
                            }

                            #else

                            SpriteRenderer ren = trans.gameObject.GetComponent<SpriteRenderer>();
                            if(ren!=null){
                                ren.color = new Color( ren.color.r, ren.color.g, ren.color.b, val);
                            }else{
                                if(trans.gameObject.renderer!=null){
                                    foreach(Material mat in trans.gameObject.renderer.materials){
                                        mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val);
                                    }
                                }
                                if(trans.childCount>0){
                                    foreach (Transform child in trans) {
                                        if(child.gameObject.renderer!=null){
                                            foreach(Material mat in child.gameObject.renderer.materials){
                                                mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val);
                                            }
                                        }
                                    }
                                }
                            }

                            #endif
                        }else if(tweenAction==TweenAction.ALPHA_VERTEX){
                            Mesh mesh = trans.GetComponent<MeshFilter>().mesh;
                            Vector3[] vertices = mesh.vertices;
                            Color32[] colors = new Color32[vertices.Length];
                            Color32 c = mesh.colors32[0];
                            c = new Color( c.r, c.g, c.b, val);
                            for (int k= 0; k < vertices.Length; k++) {
                                colors[k] = c;
                            }
                            mesh.colors32 = colors;
                        }else if(tweenAction==TweenAction.COLOR || tweenAction==TweenAction.CALLBACK_COLOR){
                            Color toColor = tweenColor(tween, val);
                            // Debug.Log("val:"+val+" tween:"+tween+" tween.diff:"+tween.diff);
                            if(tweenAction==TweenAction.COLOR){
                                if(trans.gameObject.renderer!=null){
                                    foreach(Material mat in trans.gameObject.renderer.materials){
                                        mat.color = toColor;
                                    }
                                }
                            }else if(tweenAction==TweenAction.CALLBACK_COLOR){
                                tween.onUpdateColor(toColor);
                            }
                        }

                    }else if(tweenAction>=TweenAction.MOVE){
                        //

                        if(tween.animationCurve!=null){
                            newVect = tweenOnCurveVector(tween, ratioPassed);
                        }else{
                            if(tween.tweenType == LeanTweenType.linear){
                                newVect = new Vector3( tween.from.x + tween.diff.x * ratioPassed, tween.from.y + tween.diff.y * ratioPassed, tween.from.z + tween.diff.z * ratioPassed);
                            }else if(tween.tweenType >= LeanTweenType.linear){
                                switch(tween.tweenType){
                                    case LeanTweenType.easeOutQuad:
                                        newVect = new Vector3(easeOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeOutQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeOutQuadOpt(tween.from.z, tween.diff.z, ratioPassed)); break;
                                    case LeanTweenType.easeInQuad:
                                        newVect = new Vector3(easeInQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeInQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeInQuadOpt(tween.from.z, tween.diff.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutQuad:
                                        newVect = new Vector3(easeInOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeInOutQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeInOutQuadOpt(tween.from.z, tween.diff.z, ratioPassed)); break;
                                    case LeanTweenType.easeInCubic:
                                        newVect = new Vector3(easeInCubic(tween.from.x, tween.to.x, ratioPassed), easeInCubic(tween.from.y, tween.to.y, ratioPassed), easeInCubic(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutCubic:
                                        newVect = new Vector3(easeOutCubic(tween.from.x, tween.to.x, ratioPassed), easeOutCubic(tween.from.y, tween.to.y, ratioPassed), easeOutCubic(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutCubic:
                                        newVect = new Vector3(easeInOutCubic(tween.from.x, tween.to.x, ratioPassed), easeInOutCubic(tween.from.y, tween.to.y, ratioPassed), easeInOutCubic(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInQuart:
                                        newVect = new Vector3(easeInQuart(tween.from.x, tween.to.x, ratioPassed), easeInQuart(tween.from.y, tween.to.y, ratioPassed), easeInQuart(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutQuart:
                                        newVect = new Vector3(easeOutQuart(tween.from.x, tween.to.x, ratioPassed), easeOutQuart(tween.from.y, tween.to.y, ratioPassed), easeOutQuart(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutQuart:
                                        newVect = new Vector3(easeInOutQuart(tween.from.x, tween.to.x, ratioPassed), easeInOutQuart(tween.from.y, tween.to.y, ratioPassed), easeInOutQuart(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInQuint:
                                        newVect = new Vector3(easeInQuint(tween.from.x, tween.to.x, ratioPassed), easeInQuint(tween.from.y, tween.to.y, ratioPassed), easeInQuint(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutQuint:
                                        newVect = new Vector3(easeOutQuint(tween.from.x, tween.to.x, ratioPassed), easeOutQuint(tween.from.y, tween.to.y, ratioPassed), easeOutQuint(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutQuint:
                                        newVect = new Vector3(easeInOutQuint(tween.from.x, tween.to.x, ratioPassed), easeInOutQuint(tween.from.y, tween.to.y, ratioPassed), easeInOutQuint(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInSine:
                                        newVect = new Vector3(easeInSine(tween.from.x, tween.to.x, ratioPassed), easeInSine(tween.from.y, tween.to.y, ratioPassed), easeInSine(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutSine:
                                        newVect = new Vector3(easeOutSine(tween.from.x, tween.to.x, ratioPassed), easeOutSine(tween.from.y, tween.to.y, ratioPassed), easeOutSine(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutSine:
                                        newVect = new Vector3(easeInOutSine(tween.from.x, tween.to.x, ratioPassed), easeInOutSine(tween.from.y, tween.to.y, ratioPassed), easeInOutSine(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInExpo:
                                        newVect = new Vector3(easeInExpo(tween.from.x, tween.to.x, ratioPassed), easeInExpo(tween.from.y, tween.to.y, ratioPassed), easeInExpo(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutExpo:
                                        newVect = new Vector3(easeOutExpo(tween.from.x, tween.to.x, ratioPassed), easeOutExpo(tween.from.y, tween.to.y, ratioPassed), easeOutExpo(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutExpo:
                                        newVect = new Vector3(easeInOutExpo(tween.from.x, tween.to.x, ratioPassed), easeInOutExpo(tween.from.y, tween.to.y, ratioPassed), easeInOutExpo(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInCirc:
                                        newVect = new Vector3(easeInCirc(tween.from.x, tween.to.x, ratioPassed), easeInCirc(tween.from.y, tween.to.y, ratioPassed), easeInCirc(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutCirc:
                                        newVect = new Vector3(easeOutCirc(tween.from.x, tween.to.x, ratioPassed), easeOutCirc(tween.from.y, tween.to.y, ratioPassed), easeOutCirc(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutCirc:
                                        newVect = new Vector3(easeInOutCirc(tween.from.x, tween.to.x, ratioPassed), easeInOutCirc(tween.from.y, tween.to.y, ratioPassed), easeInOutCirc(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInBounce:
                                        newVect = new Vector3(easeInBounce(tween.from.x, tween.to.x, ratioPassed), easeInBounce(tween.from.y, tween.to.y, ratioPassed), easeInBounce(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutBounce:
                                        newVect = new Vector3(easeOutBounce(tween.from.x, tween.to.x, ratioPassed), easeOutBounce(tween.from.y, tween.to.y, ratioPassed), easeOutBounce(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutBounce:
                                        newVect = new Vector3(easeInOutBounce(tween.from.x, tween.to.x, ratioPassed), easeInOutBounce(tween.from.y, tween.to.y, ratioPassed), easeInOutBounce(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInBack:
                                        newVect = new Vector3(easeInBack(tween.from.x, tween.to.x, ratioPassed), easeInBack(tween.from.y, tween.to.y, ratioPassed), easeInBack(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutBack:
                                        newVect = new Vector3(easeOutBack(tween.from.x, tween.to.x, ratioPassed), easeOutBack(tween.from.y, tween.to.y, ratioPassed), easeOutBack(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutBack:
                                        newVect = new Vector3(easeInOutBack(tween.from.x, tween.to.x, ratioPassed), easeInOutBack(tween.from.y, tween.to.y, ratioPassed), easeInOutBack(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInElastic:
                                        newVect = new Vector3(easeInElastic(tween.from.x, tween.to.x, ratioPassed), easeInElastic(tween.from.y, tween.to.y, ratioPassed), easeInElastic(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutElastic:
                                        newVect = new Vector3(easeOutElastic(tween.from.x, tween.to.x, ratioPassed), easeOutElastic(tween.from.y, tween.to.y, ratioPassed), easeOutElastic(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutElastic:
                                        newVect = new Vector3(easeInOutElastic(tween.from.x, tween.to.x, ratioPassed), easeInOutElastic(tween.from.y, tween.to.y, ratioPassed), easeInOutElastic(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.punch:
                                    case LeanTweenType.easeShake:
                                        if(tween.tweenType==LeanTweenType.punch){
                                            tween.animationCurve = LeanTween.punch;
                                        }else if(tween.tweenType==LeanTweenType.easeShake){
                                            tween.animationCurve = LeanTween.shake;
                                        }
                                        tween.to = tween.from + tween.to;
                                        tween.diff = tween.to - tween.from;
                                        if(tweenAction==TweenAction.ROTATE || tweenAction==TweenAction.ROTATE_LOCAL){
                                            tween.to = new Vector3(closestRot(tween.from.x, tween.to.x), closestRot(tween.from.y, tween.to.y), closestRot(tween.from.z, tween.to.z));
                                        }
                                        newVect = tweenOnCurveVector(tween, ratioPassed); break;
                                    case LeanTweenType.easeSpring:
                                        newVect = new Vector3(spring(tween.from.x, tween.to.x, ratioPassed), spring(tween.from.y, tween.to.y, ratioPassed), spring(tween.from.z, tween.to.z, ratioPassed)); break;

                                }
                            }else{
                                newVect = new Vector3( tween.from.x + tween.diff.x * ratioPassed, tween.from.y + tween.diff.y * ratioPassed, tween.from.z + tween.diff.z * ratioPassed);
                            }
                        }

                        if(tweenAction==TweenAction.MOVE){
                            trans.position = newVect;
                        }else if(tweenAction==TweenAction.MOVE_LOCAL){
                            trans.localPosition = newVect;
                        }else if(tweenAction==TweenAction.ROTATE){
                            /*if(tween.hasPhysics){
                                trans.gameObject.rigidbody.MoveRotation(Quaternion.Euler( newVect ));
                            }else{*/
                                trans.eulerAngles = newVect;
                            // }
                        }else if(tweenAction==TweenAction.ROTATE_LOCAL){
                            trans.localEulerAngles = newVect;
                        }else if(tweenAction==TweenAction.SCALE){
                            trans.localScale = newVect;
                        }else if(tweenAction==TweenAction.GUI_MOVE){
                            tween.ltRect.rect = new Rect( newVect.x, newVect.y, tween.ltRect.rect.width, tween.ltRect.rect.height);
                        }else if(tweenAction==TweenAction.GUI_MOVE_MARGIN){
                            tween.ltRect.margin = new Vector2(newVect.x, newVect.y);
                        }else if(tweenAction==TweenAction.GUI_SCALE){
                            tween.ltRect.rect = new Rect( tween.ltRect.rect.x, tween.ltRect.rect.y, newVect.x, newVect.y);
                        }else if(tweenAction==TweenAction.GUI_ALPHA){
                            tween.ltRect.alpha = newVect.x;
                        }else if(tweenAction==TweenAction.GUI_ROTATE){
                            tween.ltRect.rotation = newVect.x;
                        }
                    }
                    //Debug.Log("tween.delay:"+tween.delay + " tween.passed:"+tween.passed + " tweenAction:"+tweenAction + " to:"+newVect+" axis:"+tween.axis);

                    if(tween.onUpdateFloat!=null){
                        tween.onUpdateFloat(val);
                    }else if(tween.onUpdateFloatObject!=null){
                        tween.onUpdateFloatObject(val, tween.onUpdateParam);
                    }else if(tween.onUpdateVector3Object!=null){
                        tween.onUpdateVector3Object(newVect, tween.onUpdateParam);
                    }else if(tween.onUpdateVector3!=null){
                        tween.onUpdateVector3(newVect);
                    }
                    #if !UNITY_METRO
                    else if(tween.optional!=null){ // LeanTween 1.x legacy stuff

                        var onUpdate = tween.optional["onUpdate"];
                        if(onUpdate!=null){
                            Hashtable updateParam = (Hashtable)tween.optional["onUpdateParam"];
                            if((TweenAction)tweenAction==TweenAction.VALUE3){
                                if(onUpdate.GetType() == typeof(string)){
                                    string onUpdateS = onUpdate as string;
                                    customTarget = tween.optional["onUpdateTarget"]!=null ? tween.optional["onUpdateTarget"] as GameObject : trans.gameObject;
                                    customTarget.BroadcastMessage( onUpdateS, newVect );
                                }else if(onUpdate.GetType() == typeof(System.Action<Vector3, Hashtable>)){
                                    System.Action<Vector3, Hashtable> onUpdateA = (System.Action<Vector3, Hashtable>)onUpdate;
                                    onUpdateA(newVect, updateParam);
                                }else{
                                    System.Action<Vector3> onUpdateA = (System.Action<Vector3>)onUpdate;
                                    onUpdateA(newVect);
                                }
                            }else{
                                if(onUpdate.GetType() == typeof(string)){
                                    string onUpdateS = onUpdate as string;
                                    if (tween.optional["onUpdateTarget"]!=null){
                                        customTarget = tween.optional["onUpdateTarget"] as GameObject;
                                        customTarget.BroadcastMessage( onUpdateS, val );
                                    }else{
                                        trans.gameObject.BroadcastMessage( onUpdateS, val );
                                    }
                                }else if(onUpdate.GetType() == typeof(System.Action<float, Hashtable>)){
                                    System.Action<float, Hashtable> onUpdateA = (System.Action<float, Hashtable>)onUpdate;
                                    onUpdateA(val, updateParam);
                                }else if(onUpdate.GetType() == typeof(System.Action<Vector3>)){
                                    System.Action<Vector3> onUpdateA = (System.Action<Vector3>)onUpdate;
                                    onUpdateA( newVect );
                                }else{
                                    System.Action<float> onUpdateA = (System.Action<float>)onUpdate;
                                    onUpdateA(val);
                                }
                            }
                        }
                    }
                    #endif
                }

                if(isTweenFinished){
                    // Debug.Log("finished tween:"+i+" tween:"+tween);
                    if(tweenAction==TweenAction.GUI_ROTATE)
                        tween.ltRect.rotateFinished = true;

                    if(tween.loopType==LeanTweenType.once || tween.loopCount==1){
                        if(tweenAction==TweenAction.DELAYED_SOUND){
                            AudioSource.PlayClipAtPoint((AudioClip)tween.onCompleteParam, tween.to, tween.from.x);
                        }
                        if(tween.onComplete!=null){
                            removeTween(i);
                            tween.onComplete();

                        }else if(tween.onCompleteObject!=null){
                            removeTween(i);
                            tween.onCompleteObject(tween.onCompleteParam);
                        }

                        #if !UNITY_METRO
                        else if(tween.optional!=null){
                            System.Action callback=null;
                            System.Action<object> callbackWithParam = null;
                            string callbackS=string.Empty;
                            object callbackParam=null;
                            if(tween.optional!=null && tween.trans){
                                if(tween.optional["onComplete"]!=null){
                                    callbackParam = tween.optional["onCompleteParam"];
                                    if(tween.optional["onComplete"].GetType()==typeof(string)){
                                        callbackS = tween.optional["onComplete"] as string;
                                    }else{
                                        if(callbackParam!=null){
                                            callbackWithParam = (System.Action<object>)tween.optional["onComplete"];
                                        }else{
                                            callback = (System.Action)tween.optional["onComplete"];
                                            if(callback==null)
                                                Debug.LogWarning("callback was not converted");
                                        }
                                    }
                                }
                            }
                            removeTween(i);
                            if(callbackWithParam!=null){
                                callbackWithParam( callbackParam );
                            }else if(callback!=null){
                                callback();
                            }else if(callbackS!=string.Empty){
                                if (tween.optional["onCompleteTarget"]!=null){
                                    customTarget = tween.optional["onCompleteTarget"] as GameObject;
                                    if(callbackParam!=null) customTarget.BroadcastMessage ( callbackS, callbackParam );
                                    else customTarget.BroadcastMessage( callbackS );
                                }else{
                                    if(callbackParam!=null) trans.gameObject.BroadcastMessage ( callbackS, callbackParam );
                                    else trans.gameObject.BroadcastMessage( callbackS );
                                }
                            }
                        }
                        #endif
                        else{
                            removeTween(i);
                        }
                    }else{
                        if((tween.loopCount<0 && tween.type==TweenAction.CALLBACK) || tween.onCompleteOnRepeat){
                            if(tweenAction==TweenAction.DELAYED_SOUND){
                                AudioSource.PlayClipAtPoint((AudioClip)tween.onCompleteParam, tween.to, tween.from.x);
                            }
                            if(tween.onComplete!=null){
                                tween.onComplete();
                            }else if(tween.onCompleteObject!=null){
                                tween.onCompleteObject(tween.onCompleteParam);
                            }
                        }
                        if(tween.loopCount>=1){
                            tween.loopCount--;
                        }
                        if(tween.loopType==LeanTweenType.clamp){
                            tween.passed = Mathf.Epsilon;
                            // tween.delay = 0.0;
                        }else if(tween.loopType==LeanTweenType.pingPong){
                            tween.direction = 0.0f-(tween.direction);
                        }
                    }
                }else if(tween.delay<=0){
                    tween.passed += dt*tween.direction;
                }else{
                    tween.delay -= dt;
                    // Debug.Log("dt:"+dt+" tween:"+i+" tween:"+tween);
                    if(tween.delay<0){
                        tween.passed = 0.0f;//-tween.delay
                        tween.delay = 0.0f;
                    }
                }
            }
        }

        frameRendered = Time.frameCount;
        }
    }
示例#56
0
 public LTDescr setTextAlpha()
 {
     this.type = TweenAction.TEXT_ALPHA;
     this.initInternal = ()=>{
         this.uiText = trans.gameObject.GetComponent<UnityEngine.UI.Text>();
         this.fromInternal.x = this.uiText != null ? this.uiText.color.a : 1f;
     };
     this.easeInternal = ()=>{ textAlphaRecursive( trans, easeMethod().x, this.useRecursion ); };
     return this;
 }
示例#57
0
    private static int pushNewTween( GameObject gameObject, Vector3 to, float time, TweenAction tweenAction, Hashtable optional )
    {
        init(maxTweens);
        if(gameObject==null)
        return -1;

        j = 0;
        for(i = startSearch; j < maxTweens; i++){
        if(i>=maxTweens-1)
            i = 0;
        if(tweens[i].toggle==false){
            if(i+1>tweenMaxSearch)
                tweenMaxSearch = i+1;
            startSearch = i + 1;
            break;
        }

        j++;
        if(j>=maxTweens){
            logError("LeanTween - You have run out of available spaces for tweening. To avoid this error increase the number of spaces to available for tweening when you initialize the LeanTween class ex: LeanTween.init( "+(maxTweens*2)+" );");
            return -1;
        }
        }
        tween = tweens[i];
        tween.toggle = true;
        tween.reset();
        tween.trans = gameObject.transform;
        tween.to = to;
        tween.time = time;
        tween.type = tweenAction;
        tween.optional = optional;
        tween.setId( (uint)i );
        //tween.hasPhysics = gameObject.rigidbody!=null;

        if(optional!=null){
        var ease = optional["ease"];
        //LeanTweenType ease;
        var optionsNotUsed = 0;
        if(ease!=null) {
            tween.tweenType = LeanTweenType.linear;
            if( ease.GetType() ==typeof( LeanTweenType) ){
                tween.tweenType = (LeanTweenType)ease;// Enum.Parse(typeof(LeanTweenType), optional["ease"].ToString());
            } else if(ease.GetType() == typeof(AnimationCurve)){
                tween.animationCurve = optional["ease"] as AnimationCurve;
            } else{
                string func = optional["ease"].ToString();
                if(func.Equals("easeOutQuad")){
                    tween.tweenType = LeanTweenType.easeOutQuad;
                }else if(func.Equals("easeInQuad")){
                    tween.tweenType = LeanTweenType.easeInQuad;
                }else if(func.Equals("easeInOutQuad")){
                    tween.tweenType = LeanTweenType.easeInOutQuad;
                }
            }
            optionsNotUsed++;
        }
        if(optional["rect"]!=null){
            tween.ltRect = (LTRect)optional["rect"];
            optionsNotUsed++;
        }
        if(optional["path"]!=null){
            tween.path = (LTBezierPath)optional["path"];
            optionsNotUsed++;
        }
        if(optional["delay"]!=null){
            tween.delay = (float)optional["delay"];
            optionsNotUsed++;
        }
        if(optional["useEstimatedTime"]!=null){
            tween.useEstimatedTime =(bool) optional["useEstimatedTime"];
            optionsNotUsed++;
        }
        if(optional["useFrames"]!=null){
            tween.useFrames =(bool) optional["useFrames"];
            optionsNotUsed++;
        }
        if(optional["loopType"]!=null){
            tween.loopType = (LeanTweenType)optional["loopType"];
            optionsNotUsed++;
        }
        if(optional["repeat"]!=null){
            tween.loopCount = (int)optional["repeat"];
            if(tween.loopType==LeanTweenType.once)
                tween.loopType = LeanTweenType.clamp;
            optionsNotUsed++;
        }
        if(optional["point"]!=null){
            tween.point = (Vector3)optional["point"];
            optionsNotUsed++;
        }
        if(optional["axis"]!=null){
            tween.axis = (Vector3)optional["axis"];
            optionsNotUsed++;
        }
        if(optional.Count <= optionsNotUsed)
            tween.optional = null;  // nothing else is used with the extra piece, so set to null
        }else{
        tween.optional = null;
        }
        //Debug.Log("pushing new tween["+i+"]:"+tweens[i]);

        return tweens[i].uniqueId;
    }
示例#58
0
 public LTDescr setValue3()
 {
     this.type = TweenAction.VALUE3;
     this.initInternal = ()=>{};
     this.easeInternal = this.callback;
     return this;
 }