예제 #1
0
    // 補間クラス作成
    // targetObj
    // target
    // from
    // to
    // duduration or time
    // easeType
    // onComplete
    // delay
    // isLoop
    public static PTween _tween(params object[] props)
    {
        PTweenArgs args = new PTweenArgs(props);

        object obj = args.getValue <object>("targetObj", null);

        PTweenEaseFunc easeFunc = args.getValue <PTweenEaseFunc>("easeType", PEase.Linear);
        float          duration = args.getValue <float>("duration", "time", 1.0f);

        return(tween(obj, duration, easeFunc, props));
    }
예제 #2
0
    public static PTween tween(object obj, float duration, PTweenEaseFunc easeFunc, PTweenOnComplete onComplete, params object[] props)
    {
        PTweenArgs args  = new PTweenArgs(props);
        float      delay = args.getValue <float> ("delay", 0.0f);

        if (onComplete == null)
        {
            onComplete = args.getValue <PTweenOnComplete> ("onComplate", null);
        }
        PTween rtw = null;

        if (args.isExist("from") && args.isExist("to"))
        {
            if (args.isType <int>("from"))
            {
                rtw = play <int>(obj, args, duration, easeFunc, onComplete, delay);
            }
            else if (args.isType <float>("from"))
            {
                rtw = play <float>(obj, args, duration, easeFunc, onComplete, delay);
            }
            else if (args.isType <Vector2>("from"))
            {
                rtw = play <Vector2>(obj, args, duration, easeFunc, onComplete, delay);
            }
            else if (args.isType <Vector3>("from"))
            {
                rtw = play <Vector3>(obj, args, duration, easeFunc, onComplete, delay);
            }
            else if (args.isType <Vector4>("from"))
            {
                rtw = play <Vector4>(obj, args, duration, easeFunc, onComplete, delay);
            }
            else if (args.isType <Color>("from"))
            {
                rtw = play <Color>(obj, args, duration, easeFunc, onComplete, delay);
            }
            else if (args.isType <Quaternion>("from"))
            {
                rtw = play <Quaternion>(obj, args, duration, easeFunc, onComplete, delay);
            }
            else
            {
                Debug.LogError("PTween: invalid type:" + args.getType("from"));
                return(null);
            }
        }
        return(rtw);
    }
예제 #3
0
    private static PTween play <T>(object obj, PTweenArgs args, float duration, PTweenEaseFunc easeFunc, PTweenOnComplete onComplete, float delay) where T : struct
    {
        var tw = createTween <T>() as PTween <T>;

        if (tw != null)
        {
            tw.isLoop = args.getValue <bool> ("isLoop", false);

            if (obj != null)
            {
                string valueName = args.getValue <string> ("target", null);
                if (valueName != null)
                {
                    tw.setTarget(obj, valueName);
                }

                /*if(onComplete!=null) {
                 * tw.AddOnComplete(onComplete);
                 * }*/
            }
            tw.play(args.getValue <T>("from"), args.getValue <T>("to"), duration, easeFunc, onComplete, delay);
        }
        return(tw);
    }