scaleZ() public static method

public static scaleZ ( GameObject gameObject, float to, float time ) : LTDescr,
gameObject GameObject
to float
time float
return LTDescr,
Esempio n. 1
0
    /// <summary>
    /// Performs the given tweeing event on this GameObject
    /// </summary>
    public void PerformEvent(TweenEvent tweenEvent, float duration)
    {
        // If the tween modifies position
        if ((tweenEvent.type & TweenType.Position) == TweenType.Position)
        {
            // Perform a tween on the GameObject's localPosition, lasting 'duration' seconds
            LeanTween.moveLocal(gameObject, tweenEvent.targetPosition, duration).setEase(tweenEvent.positionEasingType);
        }

        // If the tween modifies scale
        if ((tweenEvent.type & TweenType.Scale) == TweenType.Scale)
        {
            // Perform a tween on the GameObject's scale, lasting 'duration' seconds
            LeanTween.scaleX(gameObject, tweenEvent.targetScale.x, duration).setEase(tweenEvent.scaleEasingType);
            LeanTween.scaleY(gameObject, tweenEvent.targetScale.y, duration).setEase(tweenEvent.scaleEasingType);
            LeanTween.scaleZ(gameObject, tweenEvent.targetScale.z, duration).setEase(tweenEvent.scaleEasingType);
        }

        // If the tween modifies rotation
        if ((tweenEvent.type & TweenType.Rotation) == TweenType.Rotation)
        {
            // Perform a tween on the GameObject's scale, lasting 'duration' seconds
            LeanTween.rotateZ(gameObject, tweenEvent.targetAngle, duration).setEase(tweenEvent.rotationEasingType);
        }

        //Debug.Log ("PERFORM THE TWEEN: " + tweenEvent.ToString ());
        //Debug.Log ("Duration: " + duration + " seconds");
    }
Esempio n. 2
0
    public void loopTestClamp()
    {
        cube1 = GameObject.Find("Cube1");
        cube1.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
        cube1ScaleZId = LeanTween.scaleZ(cube1, 4.0f, 1.0f).setEase(LeanTweenType.easeOutElastic).setRepeat(7).setLoopClamp().id;         //

        slowShakeId = LeanTween.moveY(cube1, cube1.transform.position.y + 0.3f, 1.0f).setEase(LeanTweenType.easeInOutCirc).setRepeat(-1).setLoopPingPong().id;
    }
Esempio n. 3
0
    public void loopTestClamp()
    {
        Debug.Log("loopTestClamp");
        GameObject cube1 = GameObject.Find("Cube1");

        cube1.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
        LeanTween.scaleZ(cube1, 4.0f, 1.0f, new object[] { "ease", LeanTweenType.easeOutElastic, "useEstimatedTime", useEstimatedTime, "repeat", 7 });
    }
Esempio n. 4
0
    public void loopTestClamp()
    {
        Debug.Log("loopTestClamp Time:" + Time.time);
        GameObject cube1 = GameObject.Find("Cube1");

        cube1.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
        LeanTween.scaleZ(cube1, 4.0f, 1.0f).setEase(LeanTweenType.easeOutElastic).setRepeat(7).setLoopClamp().setUseEstimatedTime(useEstimatedTime);         //
    }
Esempio n. 5
0
 void TweenBigger()
 {
     Assert.IsFalse(LeanTween.isTweening(gameObject));
     LeanTween.scaleX(gameObject, _originalScale.x + scale * scaleAmount.x, time).setEaseInOutCirc();
     LeanTween.scaleZ(gameObject, _originalScale.z + scale * scaleAmount.z, time).setEaseInOutCirc();
     LeanTween.scaleY(gameObject, _originalScale.y + scale * scaleAmount.y, time).setEaseInOutCirc().setDelay(time * .25f);
     LeanTween.moveLocalZ(gameObject, _originalPos.z + move * (invertZ ? -1 : 1) * moveZ, time).setEaseInOutCirc();
     scaledUp = true;
 }
Esempio n. 6
0
 private void ScaleZ()
 {
     if (startOffset)
     {
         var localScale = _objRectTransform.localScale;
         localScale = new Vector3(localScale.x, localScale.y, floatFrom);
         _objRectTransform.localScale = localScale;
     }
     _tweenObject = LeanTween.scaleZ(objectToAnimate, floatTo, duration);
 }
Esempio n. 7
0
    private void ScaleZ()
    {
        RectTransform _objRectTransform = _objectToAnimate.GetComponent <RectTransform>();

        if (_startPositionOffset)
        {
            _objRectTransform.localScale = new Vector3(_objRectTransform.localScale.x, _objRectTransform.localScale.y, _floatFrom);
        }

        _tweenObject = LeanTween.scaleZ(_objectToAnimate, _floatTo, _duration);
    }
Esempio n. 8
0
        private void PlayerAnimation()
        {
            LTDescr xAxisLTDescr = LeanTween.scaleX(gameObject, endScale.x, xTime).setFrom(startScale.x).setDelay(xDelay);
            LTDescr yAxisLTDescr = LeanTween.scaleY(gameObject, endScale.y, yTime).setFrom(startScale.y).setDelay(yDelay);
            LTDescr zAxisLTDescr = LeanTween.scaleZ(gameObject, endScale.z, zTime).setFrom(startScale.z).setDelay(zDelay);

            float xTotalTime      = xTime + xDelay;
            float yTotalTime      = yTime + yDelay;
            float zTotalTime      = zTime + zDelay;
            float totalFinishTime = Mathf.Max(xTotalTime, yTotalTime, zTotalTime);
        }
Esempio n. 9
0
    // Update is called once per frame
    void Update()
    {
        puffTime -= Time.deltaTime;

        if (puffTime <= 0)
        {
            puffTime = Random.Range(minPuffTime, maxPuffTime);
            particleSystem.Emit(20);
            LeanTween.scaleZ(gameObject, initialScaleZ * 0.5f, 0.25f, new object[] { "ease", LeanTweenType.easeInQuad, "onComplete", "ScaleBack" });
        }
    }
Esempio n. 10
0
    void Start()
    {
        descr        = LeanTween.move(go, new Vector3(0f, 0, 100f), 10f);
        descr.passed = 5f;     // this should put it at the midway
        descr.updateNow();
        descr.pause();         // doesn't matter if pause after or before setting descr.passed I think if I set the passed property and paused the next frame it would work

//		LeanTween.scale(go2, Vector3.one * 4f, 10f).setEasePunch();

        LeanTween.scaleX(go2, (go2.transform.localScale * 1.5f).x, 15f).setEase(LeanTweenType.punch);
        LeanTween.scaleY(go2, (go2.transform.localScale * 1.5f).y, 15f).setEase(LeanTweenType.punch);
        LeanTween.scaleZ(go2, (go2.transform.localScale * 1.5f).z, 15f).setEase(LeanTweenType.punch);
    }
Esempio n. 11
0
    // Use this for initialization
    void Start()
    {
        soundsManager = GameObject.Find("ScriptManager").GetComponent <SoundsManager>();

        //アイテムが生成されると同時に矢印を生成
        arrowInstantPos = GameObject.Find("ArrowInstantPos").transform;
        arrow           = Instantiate(arrowPrefab, arrowInstantPos);
        //アイテムマネージャーを取得
        item_manger = GameObject.Find("ItemManager").GetComponent <Item_Manager>();
        //アイテムと矢印をアイテム削除時間後で削除
        Destroy(this.gameObject, itemDestroyTime);
        Destroy(arrow, itemDestroyTime);
        //マスクオブジェクトの取得
        maskObj = arrow.transform.Find("Mask_Base").gameObject;
        //マスクの位置をアイテム削除時間に合わせてずらしていく
        LeanTween.scaleZ(maskObj, 0, itemDestroyTime);
        //プレイヤーアビリティの取得
        playerAbility = GameObject.Find("PlayerAbility").GetComponent <PlayerAbility>();
    }
Esempio n. 12
0
        public void ShowChildren()
        {
            float time = .2f;

            // Hover button
            LeanTween.cancel(button);
            LeanTween.moveLocalZ(button, 2, time).setEaseInOutCirc();
            // Show children
            LeanTween.cancel(children.gameObject);
            children.transform.localScale = Vector3.one * .75f;
            children.alpha = 1;
            //LeanTween.value(children.gameObject, OnChildAlphaUpdate, children.alpha, 1, time);
            LeanTween.scaleX(children.gameObject, 1, time).setEaseInOutCirc();
            LeanTween.scaleZ(children.gameObject, 1, time).setEaseInOutCirc();
            LeanTween.scaleY(children.gameObject, 1, time).setEaseInOutCirc().setDelay(time * .25f);
            children.gameObject.SetActive(true);

            hoverArea.gameObject.SetActive(true);
            // hoverArea.localScale = Vector3.one * scaleOnHover;
        }
Esempio n. 13
0
        protected virtual void animDisable()
        {
            switch (disableType)
            {
            case AnimatedType.Alpha: LeanTween.alpha(targetRect, 0, duration); break;

            case AnimatedType.AlphaText: LeanTween.alphaText(targetRect, 0, duration); break;

            case AnimatedType.AlphaVertex: LeanTween.alphaVertex(targetRect.gameObject, 0, duration); break;

            case AnimatedType.Scale: LeanTween.scale(targetRect, Vector3.zero, duration); break;

            case AnimatedType.ScaleX: LeanTween.scaleX(targetRect.gameObject, 0, duration); break;

            case AnimatedType.ScaleY: LeanTween.scaleY(targetRect.gameObject, 0, duration); break;

            case AnimatedType.ScaleZ: LeanTween.scaleZ(targetRect.gameObject, 0, duration); break;

            case AnimatedType.Size: LeanTween.size(targetRect, Vector2.zero, duration); break;

            case AnimatedType.Color: LeanTween.color(targetRect, targetColor, duration); break;
            }
        }
Esempio n. 14
0
        // Code that runs on entering the state.
        public override void OnEnter()
        {
            GameObject go = Fsm.GetOwnerDefaultTarget(gameObject);

            Fsm.Event(onStartEvent);
            LTDescr tween = LeanTween.scaleZ(go, scale.Value, time.Value);

            LeanTweenID.Value = tween.id;

            tween.setEase(easeType);
            tween.setDelay(delay.Value);

            if (noOfRepeat.Value > 0)
            {
                tween.setRepeat(noOfRepeat.Value);
            }

            switch (LoopType)
            {
            case LTLoop.clamp:
                tween.setLoopClamp();
                break;

            case LTLoop.once:
                tween.setLoopOnce();
                break;

            case LTLoop.pingpong:
                tween.setLoopPingPong();
                break;
            }

            tween.setOnComplete(doOnComplete);
            tween.setOnUpdate(doOnUpdate);
            tween.setUseEstimatedTime(useEstimatedTime.Value);
            tween.setUseFrames(useFrames.Value);
        }
Esempio n. 15
0
    public void Windup(float windupTime, AfterWindup afterWindup)
    {
        _windupTime          = percent.Find(80f, windupTime);
        _fadeoutTime         = percent.Find(20f, windupTime);
        _originalSpriteAlpha = utils.GetRGBAAlphaValue(Sprite.color.a);
        _afterWindup         = afterWindup;

        ResetWindup();

        if (_maskSliderTweenId.HasValue)
        {
            LeanTween.cancel(_maskSliderTweenId.Value);
        }
        _maskSliderTweenId = LeanTween.scaleZ(WindupMaskSlider.gameObject, MaskSliderActivePoint, _windupTime).id;
        LeanTween.descr(_maskSliderTweenId.Value).setEase(LeanTweenType.linear);
        LeanTween.descr(_maskSliderTweenId.Value).setOnComplete(() =>
        {
            _maskSliderTweenId = null;
            ResetWindup();
            Show(false, overtime: true);

            _afterWindup();
        });
    }
Esempio n. 16
0
 public static LTDescr LTScaleZ(this Transform self, float to, float time)
 {
     return(LeanTween.scaleZ(self.gameObject, to, time));
 }
Esempio n. 17
0
 public static LTDescr LeanScaleZ(this Transform transform, float to, float time)
 {
     return(LeanTween.scaleZ(transform.gameObject, to, time));
 }
Esempio n. 18
0
 //LeanTween.scaleZ
 public static LTDescr LeanScaleZ(this GameObject gameObject, float to, float time)
 {
     return(LeanTween.scaleZ(gameObject, to, time));
 }
Esempio n. 19
0
 void ScaleBack()
 {
     LeanTween.scaleZ(gameObject, initialScaleZ, 0.25f, new object[] { "ease", LeanTweenType.easeOutQuad });
 }
        ////////////////////////////////////////////////////////////////////////
        // Static Methods


        public static void AnimateData(BridgeObject bridgeObject, JArray dataArray)
        {
            GameObject go = bridgeObject.gameObject;

            if (leanTweenBridge == null)
            {
                Debug.LogError("LeanTweenBridge: AnimateData: no leanTweenBridge has been created.");
                return;
            }

            foreach (JObject data in dataArray)
            {
                LTDescr    result = null;
                GameObject target = go;

                float time = 1.0f;
                if (data.ContainsKey("time"))
                {
                    time = data.GetFloat("time");
                    if (time <= 0.0f)
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: time must be > 0. data: " + data);
                        return;
                    }
                }

                if (data.ContainsKey("target"))
                {
                    string targetPath = data.GetString("target");

                    if (targetPath == "")
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: empty targetPath");
                        return;
                    }

                    Accessor accessor = null;
                    if (!Accessor.FindAccessor(
                            bridgeObject,
                            targetPath,
                            ref accessor))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: target: can't find accessor for targetPath: " + targetPath);
                        return;
                    }

                    object obj = null;
                    if (!accessor.Get(ref obj))
                    {
                        if (!accessor.conditional)
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: target: can't get accessor: " + accessor + " targetPath: " + targetPath);
                            return;
                        }
                    }

                    GameObject goTarget = obj as GameObject;
                    if (goTarget == null)
                    {
                        Transform xform = obj as Transform;
                        if (xform != null)
                        {
                            goTarget = xform.gameObject;
                        }
                        else
                        {
                            Component component = obj as Component;
                            if (component != null)
                            {
                                goTarget = component.gameObject;
                            }
                        }
                    }

                    if (goTarget == null)
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: null targetPath: " + targetPath + " obj: " + obj);
                        return;
                    }

                    //Debug.Log("LeanTweenBridge: AnimateData: targetPath: " + targetPath + " goTarget: " + goTarget);
                    target = goTarget;
                }

                var command = (string)data.GetString("command");
                if (string.IsNullOrEmpty(command))
                {
                    Debug.LogError("LeanTweenBridge: AnimateData: missing command from data: " + data);
                    return;
                }

                switch (command)
                {
                case "init":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "play":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "cancel":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "cancelAll":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "pause":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "pauseAll":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "resume":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "resumeAll":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "sequence":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "value":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "move":
                case "moveLocal":
                case "moveSpline":
                case "moveSplineLocal":

                    //Debug.Log("LeanTweenBridge: AnimateData: command: " + command + " data: " + data);

                    // TODO: handle RectTransform instead of GameObject

                    if (data.ContainsKey("position"))
                    {
                        Vector3 position = Vector3.zero;
                        if (!Bridge.mainBridge.ConvertToType <Vector3>(data["position"], ref position))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: position must be a Vector3. data: " + data);
                            return;
                        }

                        switch (command)
                        {
                        case "move":
                            result = LeanTween.move(target, position, time);
                            break;

                        case "moveLocal":
                            result = LeanTween.moveLocal(target, position, time);
                            break;

                        case "moveSpline":
                        case "moveSplineLocal":
                            Debug.LogError("LeanTweenBridge: AnimateData: position not supported for " + command + ". data: " + data);
                            return;
                        }
                    }
                    else if (data.ContainsKey("transform"))
                    {
                        Transform xform = null;

                        string path = data.GetString("transform");

                        Accessor accessor = null;
                        if (!Accessor.FindAccessor(
                                bridgeObject,
                                path,
                                ref accessor))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: transform must be a path. path: " + path + " data: " + data);
                            return;
                        }
                        object val = null;
                        if (!accessor.Get(ref val) ||
                            (val == null))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: error getting path to transform. path: " + path + " data: " + data);
                            return;
                        }

                        xform = val as Transform;

                        if (xform == null)
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: path does not point to transform. path: " + path + " data: " + data);
                            return;
                        }

                        switch (command)
                        {
                        case "move":
                            result = LeanTween.move(target, xform, time);
                            break;

                        case "moveLocal":
                        case "moveSpline":
                        case "moveSplineLocal":
                            Debug.LogError("LeanTweenBridge: AnimateData: transform not supported for " + command + ". data: " + data);
                            return;
                        }
                    }
                    else if (data.ContainsKey("path"))
                    {
                        Vector3[] path = null;
                        if (!Bridge.mainBridge.ConvertToType <Vector3[]>(data["path"], ref path))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: path must be an Vector3[]. data: " + data);
                            return;
                        }

                        switch (command)
                        {
                        case "move":
                            result = LeanTween.move(target, path, time);
                            break;

                        case "moveLocal":
                            result = LeanTween.moveLocal(target, path, time);
                            break;

                        case "moveSpline":
                            result = LeanTween.moveSpline(target, path, time);
                            break;

                        case "moveSplineLocal":
                            result = LeanTween.moveSplineLocal(target, path, time);
                            break;
                        }
                    }
                    else if (data.ContainsKey("spline"))
                    {
                        LTSpline spline = null;
                        if (!Bridge.mainBridge.ConvertToType <LTSpline>(data["spline"], ref spline))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: spline must be a LTSpline. data: " + data);
                            return;
                        }

                        switch (command)
                        {
                        case "moveSpline":
                            result = LeanTween.moveSpline(target, spline, time);
                            break;

                        case "move":
                        case "moveLocal":
                        case "moveSplineLocal":
                            Debug.LogError("LeanTweenBridge: AnimateData: spline not supported for " + command + ". data: " + data);
                            break;
                        }
                    }
                    else
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: command: " + command + " should contain position, transform, path or spline. data: " + data);
                        return;
                    }

                    break;

                case "moveX":
                case "moveY":
                case "moveZ":

                    // TODO: handle RectTransform instead of GameObject

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to parameter. data: " + data);
                        return;
                    }

                    float moveTo = data.GetFloat("to");

                    switch (command)
                    {
                    case "moveX":
                        result = LeanTween.moveX(target, moveTo, time);
                        break;

                    case "moveY":
                        result = LeanTween.moveY(target, moveTo, time);
                        break;

                    case "moveZ":
                        result = LeanTween.moveZ(target, moveTo, time);
                        break;
                    }

                    break;

                case "rotate":
                case "rotateLocal":

                    //Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);

                    // TODO: handle RectTransform instead of GameObject

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to. data: " + data);
                        return;
                    }

                    Vector3 rotateTo = Vector3.zero;
                    if (!Bridge.mainBridge.ConvertToType <Vector3>(data["to"], ref rotateTo))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: to must be an Vector3. data: " + data);
                        return;
                    }

                    switch (command)
                    {
                    case "rotate":
                        result = LeanTween.rotate(target, rotateTo, time);
                        break;

                    case "rotateLocal":
                        result = LeanTween.rotateLocal(target, rotateTo, time);
                        break;
                    }

                    break;

                case "rotateX":
                case "rotateY":
                case "rotateZ":

                    //Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);

                    // TODO: handle RectTransform instead of GameObject

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to. data: " + data);
                        return;
                    }

                    float rotateToValue = data.GetFloat("to");

                    switch (command)
                    {
                    case "rotateX":
                        result = LeanTween.rotateX(target, rotateToValue, time);
                        break;

                    case "rotateY":
                        result = LeanTween.rotateY(target, rotateToValue, time);
                        break;

                    case "rotateZ":
                        result = LeanTween.rotateZ(target, rotateToValue, time);
                        break;
                    }

                    break;

                case "rotateAround":
                case "rotateAroundLocal":

                    //Debug.Log("LeanTweenBridge: AnimateData: command: " + command + " data: " + data);

                    // TODO: handle RectTransform instead of GameObject

                    if (!data.ContainsKey("axis"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing axis. data: " + data);
                        return;
                    }

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to. data: " + data);
                        return;
                    }

                    Vector3 rotateAroundAxis = Vector3.zero;
                    if (!Bridge.mainBridge.ConvertToType <Vector3>(data["axis"], ref rotateAroundAxis))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: to must be an Vector3. data: " + data);
                        return;
                    }

                    float rotateAroundTo = data.GetFloat("to");

                    switch (command)
                    {
                    case "rotateAround":
                        result = LeanTween.rotateAround(target, rotateAroundAxis, rotateAroundTo, time);
                        break;

                    case "rotateLocalLocal":
                        result = LeanTween.rotateAroundLocal(target, rotateAroundAxis, rotateAroundTo, time);
                        break;
                    }

                    break;

                case "scale":

                    //Debug.Log("LeanTweenBridge: AnimateData: command: " + command + " data: " + data);

                    // TODO: handle RectTransform instead of GameObject

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to. data: " + data);
                        return;
                    }

                    Vector3 to      = Vector3.one;
                    JToken  toToken = data["to"];
                    if (toToken.IsNumber())
                    {
                        float s = (float)toToken;
                        to = new Vector3(s, s, s);
                    }
                    else if (toToken.IsObject())
                    {
                        if (!Bridge.mainBridge.ConvertToType <Vector3>(toToken, ref to))
                        {
                            Debug.LogError("LeanTweenBridge: AnimateData: error converting to object to Vector3. data: " + data);
                            return;
                        }
                    }
                    else
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: to should be number or object. toToken: " + toToken + " " + toToken.Type + " data: " + data);
                        return;
                    }

                    result = LeanTween.scale(target, to, time);

                    break;

                case "scaleX":
                case "scaleY":
                case "scaleZ":

                    //Debug.Log("LeanTweenBridge: AnimateData: command: " + command + " data: " + data);

                    if (!data.ContainsKey("to"))
                    {
                        Debug.LogError("LeanTweenBridge: AnimateData: missing to. data: " + data);
                        return;
                    }

                    float scaleTo = data.GetFloat("to");

                    switch (command)
                    {
                    case "scaleX":
                        result = LeanTween.scaleX(target, scaleTo, time);
                        break;

                    case "scaleY":
                        result = LeanTween.scaleY(target, scaleTo, time);
                        break;

                    case "scaleZ":
                        result = LeanTween.scaleZ(target, scaleTo, time);
                        break;
                    }

                    break;

                case "size":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    // TODO: handle RectTransform but not GameObject
                    break;

                case "alpha":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "color":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                case "colorText":
                    Debug.Log("LeanTweenBridge: AnimateData: TODO: command: " + command + " data: " + data);
                    break;

                default:
                    Debug.LogError("LeanTweenBridge: AnimateData: unknown command: " + command + " in data: " + data);
                    return;
                }

                if (result != null)
                {
/*
 *              pause
 *              resume
 *              axis
 *              delay
 *              direction
 *              ease
 *              from
 *              ignoreTimeScale
 *              loopClamp
 *              loopOnce
 *              loopPingPong
 *              onComplete
 *              onCompleteOnRepeat
 *              onCompleteOnStart
 *              onCompleteParam
 *              onStart
 *              onUpdate
 *              onUpdateParam
 *              orientToPath
 *              orientToPath2d
 *              overshoot
 *              passed
 *              period
 *              point
 *              recursive
 *              repeat
 *              scale
 *              speed
 *              time
 *              to
 *              useFrames
 *              updateNow
 */
                }
            }
        }
Esempio n. 21
0
        private void buildTween(LeanTweenItem item, float delayAdd, bool generateCode)
        {
            float delay = item.delay + delayAdd;
            bool  code  = generateCode;
            float d     = item.duration;

            // Debug.Log("item:"+item.action);
            if (item.action == TweenAction.ALPHA)
            {
                tween = code ? append("alpha", item.to.x, d) : LeanTween.alpha(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.ALPHA_VERTEX)
            {
                tween = code ? append("alphaVertex", item.to.x, d) : LeanTween.alphaVertex(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE)
            {
                tween = code ? append("move", item.to, d) : LeanTween.move(gameObject, item.to, d);
            }
            else if (item.action == TweenAction.MOVE_LOCAL)
            {
                tween = code ? append("moveLocal", item.to, d) : LeanTween.moveLocal(gameObject, item.to, d);
            }
            else if (item.action == TweenAction.MOVE_LOCAL_X)
            {
                tween = code ? append("moveLocalX", item.to.x, d) : LeanTween.moveLocalX(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_LOCAL_Y)
            {
                tween = code ? append("moveLocalY", item.to.x, d) : LeanTween.moveLocalY(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_LOCAL_Z)
            {
                tween = code ? append("moveLocalZ", item.to.x, d) : LeanTween.moveLocalZ(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_X)
            {
                tween = code ? append("moveX", item.to.x, d) : LeanTween.moveX(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_Y)
            {
                tween = code ? append("moveY", item.to.x, d) : LeanTween.moveY(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_Z)
            {
                tween = code ? append("moveZ", item.to.x, d) : LeanTween.moveZ(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.MOVE_CURVED)
            {
                tween = code ? append("move", item.bezierPath ? item.bezierPath.vec3 : null, d) : LeanTween.move(gameObject, item.bezierPath.vec3, d);
                if (item.orientToPath)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath(" + item.orientToPath + ")");
                    }
                    else
                    {
                        tween.setOrientToPath(item.orientToPath);
                    }
                }
                if (item.isPath2d)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath2d(true)");
                    }
                    else
                    {
                        tween.setOrientToPath2d(item.isPath2d);
                    }
                }
            }
            else if (item.action == TweenAction.MOVE_CURVED_LOCAL)
            {
                tween = code ? append("moveLocal", item.bezierPath ? item.bezierPath.vec3 : null, d) : LeanTween.moveLocal(gameObject, item.bezierPath.vec3, d);
                if (item.orientToPath)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath(" + item.orientToPath + ")");
                    }
                    else
                    {
                        tween.setOrientToPath(item.orientToPath);
                    }
                }
                if (item.isPath2d)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath2d(true)");
                    }
                    else
                    {
                        tween.setOrientToPath2d(item.isPath2d);
                    }
                }
            }
            else if (item.action == TweenAction.MOVE_SPLINE)
            {
                tween = code ? append("moveSpline", item.splinePath ? item.splinePath.splineVector() : null, d) : LeanTween.moveSpline(gameObject, item.splinePath.splineVector(), d);
                if (item.orientToPath)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath(" + item.orientToPath + ")");
                    }
                    else
                    {
                        tween.setOrientToPath(item.orientToPath);
                    }
                }
                if (item.isPath2d)
                {
                    if (code)
                    {
                        codeBuild.Append(".setOrientToPath2d(true)");
                    }
                    else
                    {
                        tween.setOrientToPath2d(item.isPath2d);
                    }
                }
            }
            else if (item.action == TweenAction.ROTATE)
            {
                tween = code ? append("rotate", item.to, d) : LeanTween.rotate(gameObject, item.to, d);
            }
            else if (item.action == TweenAction.ROTATE_AROUND)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.rotateAround(gameObject, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)");
                }
                else
                {
                    tween = LeanTween.rotateAround(gameObject, item.axis, item.to.x, d);
                }
            }
            else if (item.action == TweenAction.ROTATE_AROUND_LOCAL)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.rotateAroundLocal(gameObject, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)");
                }
                else
                {
                    tween = LeanTween.rotateAroundLocal(gameObject, item.axis, item.to.x, d);
                }
            }
            else if (item.action == TweenAction.ROTATE_LOCAL)
            {
                tween = code ? append("rotateLocal", item.to, d) : LeanTween.rotateLocal(gameObject, item.to, d);
            }
            else if (item.action == TweenAction.ROTATE_X)
            {
                tween = code ? append("rotateX", item.to.x, d) : LeanTween.rotateX(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.ROTATE_Y)
            {
                tween = code ? append("rotateY", item.to.x, d) : LeanTween.rotateY(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.ROTATE_Z)
            {
                tween = code ? append("rotateZ", item.to.x, d) : LeanTween.rotateZ(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.SCALE)
            {
                tween = code ? append("scale", item.to, d) : LeanTween.scale(gameObject, item.to, d);
            }
            else if (item.action == TweenAction.SCALE_X)
            {
                tween = code ? append("scaleX", item.to.x, d) : LeanTween.scaleX(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.SCALE_Y)
            {
                tween = code ? append("scaleY", item.to.x, d) : LeanTween.scaleY(gameObject, item.to.x, d);
            }
            else if (item.action == TweenAction.SCALE_Z)
            {
                tween = code ? append("scaleZ", item.to.x, d) : LeanTween.scaleZ(gameObject, item.to.x, d);
            }
                        #if !UNITY_4_3 && !UNITY_4_5
            else if (item.action == TweenAction.CANVAS_MOVE)
            {
                tween = code ? appendRect("move", item.to, d) : LeanTween.move(GetComponent <RectTransform>(), item.to, d);
            }
            else if (item.action == TweenAction.CANVAS_SCALE)
            {
                tween = code ? appendRect("scale", item.to, d) : LeanTween.scale(GetComponent <RectTransform>(), item.to, d);
            }
            else if (item.action == TweenAction.CANVAS_ROTATEAROUND)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.rotateAround(rectTransform, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)");
                }
                else
                {
                    tween = LeanTween.rotateAround(GetComponent <RectTransform>(), item.axis, item.to.x, d);
                }
            }
            else if (item.action == TweenAction.CANVAS_ROTATEAROUND_LOCAL)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.rotateAroundLocal(rectTransform, " + vecToStr(item.axis) + ", " + item.to.x + "f , " + d + "f)");
                }
                else
                {
                    tween = LeanTween.rotateAroundLocal(GetComponent <RectTransform>(), item.axis, item.to.x, d);
                }
            }
            else if (item.action == TweenAction.CANVAS_ALPHA)
            {
                tween = code ? appendRect("alpha", item.to.x, d) : LeanTween.alpha(GetComponent <RectTransform>(), item.to.x, d);
            }
            else if (item.action == TweenAction.CANVAS_COLOR)
            {
                tween = code ? appendRect("color", item.colorTo, d) : LeanTween.color(GetComponent <RectTransform>(), item.colorTo, d);
            }
            else if (item.action == TweenAction.TEXT_ALPHA)
            {
                tween = code ? appendRect("textAlpha", item.to.x, d) : LeanTween.textAlpha(GetComponent <RectTransform>(), item.to.x, d);
            }
            else if (item.action == TweenAction.TEXT_COLOR)
            {
                tween = code ? appendRect("textColor", item.colorTo, d) : LeanTween.textColor(GetComponent <RectTransform>(), item.colorTo, d);
            }
            else if (item.action == TweenAction.CANVAS_PLAYSPRITE)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.play(rectTransform, sprites).setFrameRate(" + item.frameRate + "f)");
                }
                else
                {
                    tween = LeanTween.play(GetComponent <RectTransform>(), item.sprites).setFrameRate(item.frameRate);
                }
            }
                        #endif
            else if (item.action == TweenAction.COLOR)
            {
                tween = code ? append("color", item.colorTo, d) : LeanTween.color(gameObject, item.colorTo, d);
            }
            else if (item.action == TweenAction.DELAYED_SOUND)
            {
                if (generateCode)
                {
                    codeBuild.Append(tabs + "LeanTween.delayedSound(gameObject, passAudioClipHere, " + vecToStr(item.from) + ", " + d + "f)");
                }
                else
                {
                    tween = LeanTween.delayedSound(gameObject, item.audioClip, item.from, item.duration);
                }
            }
            else
            {
                tween = null;
                Debug.Log("The tween '" + item.action.ToString() + "' has not been implemented. info item:" + item);
                return;
            }


            // Append Extras
            if (generateCode)
            {
                if (delay > 0f)
                {
                    codeBuild.Append(".setDelay(" + delay + "f)");
                }
            }
            else
            {
                tween = tween.setDelay(delay);
            }
            if (item.ease == LeanTweenType.animationCurve)
            {
                if (generateCode)
                {
                    codeBuild.Append(".setEase(");
                    append(item.animationCurve);
                    codeBuild.Append(")");
                }
                else
                {
                    tween.setEase(item.animationCurve);
                }
            }
            else
            {
                if (generateCode)
                {
                    if (item.ease != LeanTweenType.linear)
                    {
                        codeBuild.Append(".setEase(LeanTweenType." + item.ease + ")");
                    }
                }
                else
                {
                    tween.setEase(item.ease);
                }
            }
            // Debug.Log("curve:"+item.animationCurve+" item.ease:"+item.ease);
            if (item.between == LeanTweenBetween.FromTo)
            {
                if (generateCode)
                {
                    codeBuild.Append(".setFrom(" + item.from + ")");
                }
                else
                {
                    tween.setFrom(item.from);
                }
            }
            if (item.doesLoop)
            {
                if (generateCode)
                {
                    codeBuild.Append(".setRepeat(" + item.loopCount + ")");
                }
                else
                {
                    tween.setRepeat(item.loopCount);
                }

                if (item.loopType == LeanTweenType.pingPong)
                {
                    if (generateCode)
                    {
                        codeBuild.Append(".setLoopPingPong()");
                    }
                    else
                    {
                        tween.setLoopPingPong();
                    }
                }
            }
            if (generateCode)
            {
                codeBuild.Append(";\n");
            }
        }