コード例 #1
0
    static int SetEase(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <DG.Tweening.Ease>(L, 2))
            {
                DG.Tweening.Tween obj  = (DG.Tweening.Tween)ToLua.CheckObject <DG.Tweening.Tween>(L, 1);
                DG.Tweening.Ease  arg0 = (DG.Tweening.Ease)ToLua.ToObject(L, 2);
                DG.Tweening.Tween o    = obj.SetEase(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes <UnityEngine.AnimationCurve>(L, 2))
            {
                DG.Tweening.Tween          obj  = (DG.Tweening.Tween)ToLua.CheckObject <DG.Tweening.Tween>(L, 1);
                UnityEngine.AnimationCurve arg0 = (UnityEngine.AnimationCurve)ToLua.ToObject(L, 2);
                DG.Tweening.Tween          o    = obj.SetEase(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes <DG.Tweening.EaseFunction>(L, 2))
            {
                DG.Tweening.Tween        obj  = (DG.Tweening.Tween)ToLua.CheckObject <DG.Tweening.Tween>(L, 1);
                DG.Tweening.EaseFunction arg0 = (DG.Tweening.EaseFunction)ToLua.ToObject(L, 2);
                DG.Tweening.Tween        o    = obj.SetEase(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 3)
            {
                DG.Tweening.Tween obj  = (DG.Tweening.Tween)ToLua.CheckObject <DG.Tweening.Tween>(L, 1);
                DG.Tweening.Ease  arg0 = (DG.Tweening.Ease)ToLua.CheckObject(L, 2, typeof(DG.Tweening.Ease));
                float             arg1 = (float)LuaDLL.luaL_checknumber(L, 3);
                DG.Tweening.Tween o    = obj.SetEase(arg0, arg1);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 4)
            {
                DG.Tweening.Tween obj  = (DG.Tweening.Tween)ToLua.CheckObject <DG.Tweening.Tween>(L, 1);
                DG.Tweening.Ease  arg0 = (DG.Tweening.Ease)ToLua.CheckObject(L, 2, typeof(DG.Tweening.Ease));
                float             arg1 = (float)LuaDLL.luaL_checknumber(L, 3);
                float             arg2 = (float)LuaDLL.luaL_checknumber(L, 4);
                DG.Tweening.Tween o    = obj.SetEase(arg0, arg1, arg2);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: DG.Tweening.Tween.SetEase"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #2
0
    static int SetEase(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(DG.Tweening.Tween), typeof(DG.Tweening.EaseFunction)))
        {
            DG.Tweening.Tween        obj  = (DG.Tweening.Tween)LuaScriptMgr.GetNetObjectSelf(L, 1, "DG.Tweening.Tween");
            DG.Tweening.EaseFunction arg0 = null;
            LuaTypes funcType2            = LuaDLL.lua_type(L, 2);

            if (funcType2 != LuaTypes.LUA_TFUNCTION)
            {
                arg0 = (DG.Tweening.EaseFunction)LuaScriptMgr.GetLuaObject(L, 2);
            }
            else
            {
                LuaFunction func = LuaScriptMgr.GetLuaFunction(L, 2);
                arg0 = (param0, param1, param2, param3) =>
                {
                    int top = func.BeginPCall();
                    LuaScriptMgr.Push(L, param0);
                    LuaScriptMgr.Push(L, param1);
                    LuaScriptMgr.Push(L, param2);
                    LuaScriptMgr.Push(L, param3);
                    func.PCall(top, 4);
                    object[] objs = func.PopValues(top);
                    func.EndPCall(top);
                    return((float)objs[0]);
                };
            }

            DG.Tweening.Tween o = obj.SetEase(arg0);
            LuaScriptMgr.PushObject(L, o);
            return(1);
        }
        else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(DG.Tweening.Tween), typeof(AnimationCurve)))
        {
            DG.Tweening.Tween obj  = (DG.Tweening.Tween)LuaScriptMgr.GetNetObjectSelf(L, 1, "DG.Tweening.Tween");
            AnimationCurve    arg0 = (AnimationCurve)LuaScriptMgr.GetLuaObject(L, 2);
            DG.Tweening.Tween o    = obj.SetEase(arg0);
            LuaScriptMgr.PushObject(L, o);
            return(1);
        }
        else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(DG.Tweening.Tween), typeof(DG.Tweening.Ease)))
        {
            DG.Tweening.Tween obj  = (DG.Tweening.Tween)LuaScriptMgr.GetNetObjectSelf(L, 1, "DG.Tweening.Tween");
            DG.Tweening.Ease  arg0 = (DG.Tweening.Ease)LuaScriptMgr.GetLuaObject(L, 2);
            DG.Tweening.Tween o    = obj.SetEase(arg0);
            LuaScriptMgr.PushObject(L, o);
            return(1);
        }
        else if (count == 3)
        {
            DG.Tweening.Tween obj  = (DG.Tweening.Tween)LuaScriptMgr.GetNetObjectSelf(L, 1, "DG.Tweening.Tween");
            DG.Tweening.Ease  arg0 = (DG.Tweening.Ease)LuaScriptMgr.GetNetObject(L, 2, typeof(DG.Tweening.Ease));
            float             arg1 = (float)LuaScriptMgr.GetNumber(L, 3);
            DG.Tweening.Tween o    = obj.SetEase(arg0, arg1);
            LuaScriptMgr.PushObject(L, o);
            return(1);
        }
        else if (count == 4)
        {
            DG.Tweening.Tween obj  = (DG.Tweening.Tween)LuaScriptMgr.GetNetObjectSelf(L, 1, "DG.Tweening.Tween");
            DG.Tweening.Ease  arg0 = (DG.Tweening.Ease)LuaScriptMgr.GetNetObject(L, 2, typeof(DG.Tweening.Ease));
            float             arg1 = (float)LuaScriptMgr.GetNumber(L, 3);
            float             arg2 = (float)LuaScriptMgr.GetNumber(L, 4);
            DG.Tweening.Tween o    = obj.SetEase(arg0, arg1, arg2);
            LuaScriptMgr.PushObject(L, o);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: DG.Tweening.Tween.SetEase");
        }

        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();
            }
        }