예제 #1
0
    /// <summary>
    /// 寮€濮嬭ˉ闂存搷浣浱
    /// </summary>

    static public CustomTweenVolume Begin(GameObject go, float duration, float targetVolume)
    {
        CustomTweenVolume comp = CustomUITweener.Begin <CustomTweenVolume>(go, duration);

        comp.from = comp.value;
        comp.to   = targetVolume;
        return(comp);
    }
예제 #2
0
    /// <summary>
    /// 开始补间操作
    /// </summary>

    static public CustomTweenAlpha Begin(GameObject go, float duration, float alpha)
    {
        CustomTweenAlpha comp = CustomUITweener.Begin <CustomTweenAlpha>(go, duration);

        comp.from = comp.value;
        comp.to   = alpha;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
    /// <summary>
    /// 开始补间操作
    /// </summary>

    static public CustomTweenRotation Begin(GameObject go, float duration, Quaternion rot)
    {
        CustomTweenRotation comp = CustomUITweener.Begin <CustomTweenRotation>(go, duration);

        comp.from = comp.value.eulerAngles;
        comp.to   = rot.eulerAngles;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
예제 #4
0
    /// <summary>
    /// 开始补间操作
    /// </summary>
    static public CustomTweenScale Begin(GameObject go, float duration, Vector3 scale)
    {
        CustomTweenScale comp = CustomUITweener.Begin <CustomTweenScale>(go, duration);

        comp.from = comp.value;
        comp.to   = scale;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public CustomTweenTransform Begin(GameObject go, float duration, Transform from, Transform to)
    {
        CustomTweenTransform comp = CustomUITweener.Begin <CustomTweenTransform>(go, duration);

        comp.from = from;
        comp.to   = to;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
예제 #6
0
    /// <summary>
    /// 开始补间操作
    /// </summary>

    static public CustomTweenPosition Begin(GameObject go, float duration, Vector3 pos)
    {
        CustomTweenPosition comp = CustomUITweener.Begin <CustomTweenPosition>(go, duration);

        comp.from = comp.value;
        comp.to   = pos;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
예제 #7
0
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

    static public CustomTweenWidth Begin(RectTransform rectTransform, float duration, int width)
    {
        CustomTweenWidth comp = CustomUITweener.Begin <CustomTweenWidth>(rectTransform.gameObject, duration);

        comp.from = (int)rectTransform.sizeDelta.x;
        comp.to   = width;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
    /// <summary>
    /// 开始补间操作
    /// </summary>
    static public CustomTweenHeight Begin(RectTransform rectTransform, float duration, int height)
    {
        CustomTweenHeight comp = CustomUITweener.Begin <CustomTweenHeight>(rectTransform.gameObject, duration);

        comp.from = (int)rectTransform.sizeDelta.y;
        comp.to   = height;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
예제 #9
0
    public static CustomTweenText Begin(Text label, float duration, float delay, float from, float to)
    {
        CustomTweenText comp = CustomUITweener.Begin <CustomTweenText>(label.gameObject, duration);

        comp.from  = from;
        comp.to    = to;
        comp.delay = delay;

        if (duration <= 0)
        {
            comp.Sample(1, true);
            comp.enabled = false;
        }
        return(comp);
    }
예제 #10
0
    public static CustomTweenSlider Begin(Slider slider, float duration, float delay, float from, float to)
    {
        CustomTweenSlider comp = CustomUITweener.Begin <CustomTweenSlider>(slider.gameObject, duration);

        comp.from  = from;
        comp.to    = to;
        comp.delay = delay;

        if (duration <= 0)
        {
            comp.Sample(1, true);
            comp.enabled = false;
        }
        return(comp);
    }
예제 #11
0
    protected void DrawCommonProperties()
    {
        CustomUITweener tw = target as CustomUITweener;

        if (CustomUITweenEditorTools.DrawHeader("Tweener"))
        {
            CustomUITweenEditorTools.BeginContents();
            CustomUITweenEditorTools.SetLabelWidth(110f);

            GUI.changed = false;

            CustomUITweener.Style style = (CustomUITweener.Style)EditorGUILayout.EnumPopup("Play Style", tw.style);
            EaseType       easeType     = (EaseType)EditorGUILayout.EnumPopup("Ease Type", tw.easeType);
            AnimationCurve curve        = EditorGUILayout.CurveField("Animation Curve", tw.animationCurve, GUILayout.Width(170f), GUILayout.Height(62f));
            GUILayout.BeginHorizontal();
            float dur = EditorGUILayout.FloatField("Duration", tw.duration, GUILayout.Width(170f));
            GUILayout.Label("seconds");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            float del = EditorGUILayout.FloatField("Start Delay", tw.delay, GUILayout.Width(170f));
            GUILayout.Label("seconds");
            GUILayout.EndHorizontal();

            int  tg = EditorGUILayout.IntField("Tween Group", tw.tweenGroup, GUILayout.Width(170f));
            bool ts = EditorGUILayout.Toggle("Ignore TimeScale", tw.ignoreTimeScale);

            if (GUI.changed)
            {
                CustomUITweenEditorTools.RegisterUndo("Tween Change", tw);
                tw.easeType        = easeType;
                tw.style           = style;
                tw.ignoreTimeScale = ts;
                tw.tweenGroup      = tg;
                tw.duration        = dur;
                tw.delay           = del;
                CustomUITweenTools.SetDirty(tw);
            }
            CustomUITweenEditorTools.EndContents();
        }

        CustomUITweenEditorTools.SetLabelWidth(80f);
        CustomUITweenEditorTools.DrawEvents("On Finished", tw, tw.onFinished);
    }
예제 #12
0
    /// <summary>
    /// 开始补间
    /// </summary>

    static public CustomTweenColor Begin(GameObject go, float duration, Color color)
    {
#if UNITY_EDITOR
        if (!Application.isPlaying)
        {
            return(null);
        }
#endif
        CustomTweenColor comp = CustomUITweener.Begin <CustomTweenColor>(go, duration);
        comp.from = comp.value;
        comp.to   = color;

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }
예제 #13
0
    void Update()
    {
        float delta = ignoreTimeScale ? RealTime.deltaTime : Time.deltaTime;
        float time  = ignoreTimeScale ? RealTime.time : Time.time;

        if (!mStarted)
        {
            mStarted   = true;
            mStartTime = time + delay;
        }

        if (time < mStartTime)
        {
            return;
        }

        mFactor += amountPerDelta * delta;

        if (style == Style.Loop)
        {
            if (mFactor > 1f)
            {
                mFactor -= Mathf.Floor(mFactor);
            }
        }
        else if (style == Style.PingPong)
        {
            if (mFactor > 1f)
            {
                mFactor         = 1f - (mFactor - Mathf.Floor(mFactor));
                mAmountPerDelta = -mAmountPerDelta;
            }
            else if (mFactor < 0f)
            {
                mFactor         = -mFactor;
                mFactor        -= Mathf.Floor(mFactor);
                mAmountPerDelta = -mAmountPerDelta;
            }
        }

        if ((style == Style.Once) && (duration == 0f || mFactor > 1f || mFactor < 0f))
        {
            mFactor = Mathf.Clamp01(mFactor);
            Sample(mFactor, true);

            if (duration == 0f || (mFactor == 1f && mAmountPerDelta > 0f || mFactor == 0f && mAmountPerDelta < 0f))
            {
                enabled = false;
            }

            if (current == null)
            {
                current = this;

                if (onFinished != null)
                {
                    mTemp      = onFinished;
                    onFinished = new List <EventDelegate>();

                    EventDelegate.Execute(mTemp);

                    for (int i = 0; i < mTemp.Count; ++i)
                    {
                        EventDelegate ed = mTemp[i];
                        if (ed != null)
                        {
                            EventDelegate.Add(onFinished, ed, ed.oneShot);
                        }
                    }
                    mTemp = null;
                }

                current = null;
            }
        }
        else
        {
            Sample(mFactor, false);
        }
    }