示例#1
0
    public override void OnInspectorGUI()
    {
        GUILayout.Space(6f);
        NGUIEditorTools.SetLabelWidth(120f);

        TweenMaterialColor tw = target as TweenMaterialColor;

        GUI.changed = false;

        string colorName = EditorGUILayout.TextField("Color Name", tw.colorName);
        Color  from      = EditorGUILayout.ColorField("From", tw.from);
        Color  to        = EditorGUILayout.ColorField("To", tw.to);

        if (GUI.changed)
        {
            NGUIEditorTools.RegisterUndo("Tween Change", tw);
            tw.colorName = colorName;
            tw.from      = from;
            tw.to        = to;
            if (preview)
            {
                tw.Sample(tw.tweenFactor, false);
            }
            NGUITools.SetDirty(tw);
        }

        DrawCommonProperties();
    }
    /// <summary>
    /// Start the tweening operation.
    /// </summary>

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

        if (duration <= 0f)
        {
            comp.Sample(1f, true);
            comp.enabled = false;
        }
        return(comp);
    }