static int SetRelative(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                DG.Tweening.Tween obj = (DG.Tweening.Tween)ToLua.CheckObject <DG.Tweening.Tween>(L, 1);
                DG.Tweening.Tween o   = obj.SetRelative();
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 2)
            {
                DG.Tweening.Tween obj = (DG.Tweening.Tween)ToLua.CheckObject <DG.Tweening.Tween>(L, 1);
                bool arg0             = LuaDLL.luaL_checkboolean(L, 2);
                DG.Tweening.Tween o   = obj.SetRelative(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: DG.Tweening.Tween.SetRelative"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
    static int SetRelative(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 1)
        {
            DG.Tweening.Tween obj = (DG.Tweening.Tween)LuaScriptMgr.GetNetObjectSelf(L, 1, "DG.Tweening.Tween");
            DG.Tweening.Tween o   = obj.SetRelative();
            LuaScriptMgr.PushObject(L, o);
            return(1);
        }
        else if (count == 2)
        {
            DG.Tweening.Tween obj = (DG.Tweening.Tween)LuaScriptMgr.GetNetObjectSelf(L, 1, "DG.Tweening.Tween");
            bool arg0             = LuaScriptMgr.GetBoolean(L, 2);
            DG.Tweening.Tween o   = obj.SetRelative(arg0);
            LuaScriptMgr.PushObject(L, o);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: DG.Tweening.Tween.SetRelative");
        }

        return(0);
    }
示例#3
0
        int _playCount = -1; // Used when calling DOPlayNext

        #region Unity Methods

        void Awake()
        {
            if (!isValid)
            {
                return;
            }

            Component c;

            switch (animationType)
            {
            case DOTweenAnimationType.None:
                break;

            case DOTweenAnimationType.Move:
                c = this.GetComponent <Rigidbody2D>();
                if (c != null)
                {
                    _tween = ((Rigidbody2D)c).DOMove(endValueV3, duration, optionalBool0);
                    goto SetupTween;
                }
                c = this.GetComponent <Rigidbody>();
                if (c != null)
                {
                    _tween = ((Rigidbody)c).DOMove(endValueV3, duration, optionalBool0);
                    goto SetupTween;
                }
                _tween = transform.DOMove(endValueV3, duration, optionalBool0);
                break;

            case DOTweenAnimationType.LocalMove:
                _tween = transform.DOLocalMove(endValueV3, duration, optionalBool0);
                break;

            case DOTweenAnimationType.Rotate:
                c = this.GetComponent <Rigidbody2D>();
                if (c != null)
                {
                    _tween = ((Rigidbody2D)c).DORotate(endValueFloat, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <Rigidbody>();
                if (c != null)
                {
                    _tween = ((Rigidbody)c).DORotate(endValueV3, duration, optionalRotationMode);
                    goto SetupTween;
                }
                _tween = transform.DORotate(endValueV3, duration, optionalRotationMode);
                break;

            case DOTweenAnimationType.LocalRotate:
                _tween = transform.DOLocalRotate(endValueV3, duration, optionalRotationMode);
                break;

            case DOTweenAnimationType.Scale:
                _tween = transform.DOScale(optionalBool0 ? new Vector3(endValueFloat, endValueFloat, endValueFloat) : endValueV3, duration);
                break;

            case DOTweenAnimationType.Color:
                isRelative = false;
#if TK2D
                c = this.GetComponent <tk2dBaseSprite>();
                if (c != null)
                {
                    _tween = ((tk2dBaseSprite)c).DOColor(endValueColor, duration);
                    goto SetupTween;
                }
#endif
#if TEXTMESHPRO
                c = this.GetComponent <TextMeshPro>();
                if (c != null)
                {
                    _tween = ((TextMeshPro)c).DOColor(endValueColor, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <TextMeshProUGUI>();
                if (c != null)
                {
                    _tween = ((TextMeshProUGUI)c).DOColor(endValueColor, duration);
                    goto SetupTween;
                }
#endif
                c = this.GetComponent <SpriteRenderer>();
                if (c != null)
                {
                    _tween = ((SpriteRenderer)c).DOColor(endValueColor, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <Renderer>();
                if (c != null)
                {
                    _tween = ((Renderer)c).material.DOColor(endValueColor, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <Image>();
                if (c != null)
                {
                    _tween = ((Image)c).DOColor(endValueColor, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <Text>();
                if (c != null)
                {
                    _tween = ((Text)c).DOColor(endValueColor, duration);
                    goto SetupTween;
                }
                break;

            case DOTweenAnimationType.Fade:
                isRelative = false;
#if TK2D
                c = this.GetComponent <tk2dBaseSprite>();
                if (c != null)
                {
                    _tween = ((tk2dBaseSprite)c).DOFade(endValueFloat, duration);
                    goto SetupTween;
                }
#endif
#if TEXTMESHPRO
                c = this.GetComponent <TextMeshPro>();
                if (c != null)
                {
                    _tween = ((TextMeshPro)c).DOFade(endValueFloat, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <TextMeshProUGUI>();
                if (c != null)
                {
                    _tween = ((TextMeshProUGUI)c).DOFade(endValueFloat, duration);
                    goto SetupTween;
                }
#endif
                c = this.GetComponent <SpriteRenderer>();
                if (c != null)
                {
                    _tween = ((SpriteRenderer)c).DOFade(endValueFloat, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <Renderer>();
                if (c != null)
                {
                    _tween = ((Renderer)c).material.DOFade(endValueFloat, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <Image>();
                if (c != null)
                {
                    _tween = ((Image)c).DOFade(endValueFloat, duration);
                    goto SetupTween;
                }
                c = this.GetComponent <Text>();
                if (c != null)
                {
                    _tween = ((Text)c).DOFade(endValueFloat, duration);
                    goto SetupTween;
                }
                break;

            case DOTweenAnimationType.Text:
                c = this.GetComponent <Text>();
                if (c != null)
                {
                    _tween = ((Text)c).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString);
                    goto SetupTween;
                }
#if TK2D
                c = this.GetComponent <tk2dTextMesh>();
                if (c != null)
                {
                    _tween = ((tk2dTextMesh)c).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString);
                    goto SetupTween;
                }
#endif
#if TEXTMESHPRO
                c = this.GetComponent <TextMeshPro>();
                if (c != null)
                {
                    _tween = ((TextMeshPro)c).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString);
                    goto SetupTween;
                }
                c = this.GetComponent <TextMeshProUGUI>();
                if (c != null)
                {
                    _tween = ((TextMeshProUGUI)c).DOText(endValueString, duration, optionalBool0, optionalScrambleMode, optionalString);
                    goto SetupTween;
                }
#endif
                break;

            case DOTweenAnimationType.PunchPosition:
                _tween = transform.DOPunchPosition(endValueV3, duration, optionalInt0, optionalFloat0, optionalBool0);
                break;

            case DOTweenAnimationType.PunchScale:
                _tween = transform.DOPunchScale(endValueV3, duration, optionalInt0, optionalFloat0);
                break;

            case DOTweenAnimationType.PunchRotation:
                _tween = transform.DOPunchRotation(endValueV3, duration, optionalInt0, optionalFloat0);
                break;

            case DOTweenAnimationType.ShakePosition:
                _tween = transform.DOShakePosition(duration, endValueV3, optionalInt0, optionalFloat0, optionalBool0);
                break;

            case DOTweenAnimationType.ShakeScale:
                _tween = transform.DOShakeScale(duration, endValueV3, optionalInt0, optionalFloat0);
                break;

            case DOTweenAnimationType.ShakeRotation:
                _tween = transform.DOShakeRotation(duration, endValueV3, optionalInt0, optionalFloat0);
                break;
            }

SetupTween:
            if (_tween == null)
            {
                return;
            }

            if (isFrom)
            {
                ((Tweener)_tween).From(isRelative);
            }
            else
            {
                _tween.SetRelative(isRelative);
            }
            _tween.SetTarget(this.gameObject).SetDelay(delay).SetLoops(loops, loopType).SetAutoKill(autoKill)
            .OnKill(() => _tween = null);
            if (easeType == Ease.INTERNAL_Custom)
            {
                _tween.SetEase(easeCurve);
            }
            else
            {
                _tween.SetEase(easeType);
            }
            if (!string.IsNullOrEmpty(id))
            {
                _tween.SetId(id);
            }

            if (hasOnStart)
            {
                if (onStart != null)
                {
                    _tween.OnStart(onStart.Invoke);
                }
            }
            else
            {
                onStart = null;
            }
            if (hasOnStepComplete)
            {
                if (onStepComplete != null)
                {
                    _tween.OnStepComplete(onStepComplete.Invoke);
                }
            }
            else
            {
                onStepComplete = null;
            }
            if (hasOnComplete)
            {
                if (onComplete != null)
                {
                    _tween.OnComplete(onComplete.Invoke);
                }
            }
            else
            {
                onComplete = null;
            }

            if (autoPlay)
            {
                _tween.Play();
            }
            else
            {
                _tween.Pause();
            }
        }