示例#1
0
    public static void ColorTo(object obj, Hashtable ht)
    {
        if (obj.GetType() != typeof(GameObject))
        {
            Debug.LogError("This object must be of type GameObject. vp_UITween.ColorTo cannot proceed.");
            return;
        }

        GameObject go = (GameObject)obj;

        if (go.GetComponent <Renderer>() == null)
        {
            Debug.LogError("This GameObject does not have a renderer. vp_UITween.ColorTo cannot proceed.");
            return;
        }

        Color alpha = go.GetComponent <Renderer>().material.color;

        alpha.a = ht["color"].GetType() == typeof(float) ? (float)ht["color"] : alpha.a;
        Color color = ht["color"].GetType() == typeof(float) ? alpha : (Color)ht["color"];

        vp_UITween.Tween tween = null;
        if (!Instance.Tweens.TryGetValue((vp_UITween.Handle)ht["handle"], out tween))
        {
            tween = new vp_UITween.Tween(obj, "startColor", go.GetComponent <Renderer>().material.color, "endColor", color, "duration", ht["duration"], "handle", ht["handle"], "onComplete", ht["onComplete"], "type", vp_UITween.vp_UITweenType.Color);
            Instance.Tweens.Add((vp_UITween.Handle)ht["handle"], tween);
        }

        tween.ColorCheck(obj, go.GetComponent <Renderer>().material.color, color, ht["duration"], ht["onComplete"]);
    }
示例#2
0
    /// <summary>
    /// updates the color for a tween
    /// </summary>
    protected virtual void ColorUpdate(vp_UITween.Tween tween)
    {
        if (tween.Type != vp_UITween.vp_UITweenType.Color)
        {
            return;
        }

        if (tween.ElapsedTime < tween.Duration)
        {
            // lerp the color
            tween.CurrentColor = Color.Lerp(tween.StartColor, tween.EndColor, (tween.ElapsedTime / tween.Duration));

            // update the color on the object
            tween.ColorUpdate();

            // update the elapsed time
            tween.ElapsedTime += Time.deltaTime;

            return;
        }

        if (tween.CurrentColor != tween.EndColor)
        {
            tween.CurrentColor = tween.EndColor;
            tween.ColorUpdate();
        }

        // callback
        if (tween.Callback != null)
        {
            tween.Callback();
        }

        if (!tween.Handle.Custom)        // destroy the tween if no handle was provided
        {
            Instance.Tweens.Remove(tween.Handle);
        }
        else                                            // set to inactive if a handle was provided
        {
            tween.Handle.Active = false;
        }
    }
示例#3
0
    /// <summary>
    /// updates the rotation for a tween
    /// </summary>
    protected virtual void RotationUpdate(vp_UITween.Tween tween)
    {
        if (tween.Type != vp_UITween.vp_UITweenType.Rotation || !tween.Handle.Active)
        {
            return;
        }

        if (tween.ElapsedTime < tween.Duration)
        {
            // lerp the color
            tween.CurrentRotation = Quaternion.Lerp(tween.StartRotation, tween.EndRotation, (tween.ElapsedTime / tween.Duration));

            // update the color on the object
            tween.Transform.localRotation = tween.CurrentRotation;

            // update the elapsed time
            tween.ElapsedTime += Time.deltaTime;

            return;
        }

        if (tween.Transform.localRotation != tween.EndRotation)
        {
            tween.Transform.localRotation = tween.EndRotation;
        }

        // callback
        if (tween.Callback != null)
        {
            tween.Callback();
        }

        if (!tween.Handle.Custom)        // destroy the tween if no handle was provided
        {
            Instance.Tweens.Remove(tween.Handle);
        }
        else                                            // set to inactive if a handle was provided
        {
            tween.Handle.Active = false;
        }
    }
示例#4
0
    /// <summary>
    /// Creates or updates a Rotate Tween
    /// </summary>
    public static void RotateTo(object obj, Hashtable ht)
    {
        if (obj.GetType() != typeof(GameObject))
        {
            Debug.LogError("This object must be of type GameObject. vp_UITween.ColorTween cannot proceed.");
            return;
        }

        vp_UITween.Tween tween = null;
        if (!Instance.Tweens.TryGetValue((vp_UITween.Handle)ht["handle"], out tween))
        {
            tween = new vp_UITween.Tween(obj, "rotation", ht["rotation"], "duration", ht["duration"], "handle", ht["handle"], "onComplete", ht["onComplete"], "type", vp_UITween.vp_UITweenType.Rotation);
            Instance.Tweens.Add((vp_UITween.Handle)ht["handle"], tween);
        }

        if (Convert.ToSingle(ht["duration"]) == 0)
        {
            tween.Transform.localRotation = (Quaternion)ht["rotation"];
        }

        tween.RotationCheck(obj, ht["rotation"], ht["duration"], ht["onComplete"]);
    }
示例#5
0
    public static void ColorTo(object obj, Hashtable ht)
    {
        if (obj.GetType().BaseType != typeof(UIWidget))
        {
            Debug.LogError("This object must be of type UIWidget. vp_NGUITween.ColorTo cannot proceed.");
            return;
        }

        UIWidget widget = (UIWidget)obj;

        Color alpha = widget.color;

        alpha.a = ht["color"].GetType() == typeof(float) ? (float)ht["color"] : alpha.a;
        Color color = ht["color"].GetType() == typeof(float) ? alpha : (Color)ht["color"];

        vp_UITween.Tween tween = null;
        if (!Instance.Tweens.TryGetValue((vp_UITween.Handle)ht["handle"], out tween))
        {
            tween = new vp_NGUITween.TweenNGUI(obj, "startColor", widget.color, "endColor", color, "duration", ht["duration"], "handle", ht["handle"], "onComplete", ht["onComplete"], "type", vp_UITween.vp_UITweenType.Color);
            Instance.Tweens.Add((vp_UITween.Handle)ht["handle"], tween);
        }

        tween.ColorCheck(obj, widget.color, color, ht["duration"], ht["onComplete"]);
    }
示例#6
0
 /// <summary>
 /// Gets the handle for the specified object
 /// </summary>
 public static vp_UITween.Handle GetHandleForObject(object obj)
 {
     vp_UITween.Tween tween = GetTweenForObject(obj);
     return(tween != null ? tween.Handle : null);
 }