// ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    protected virtual void DoInspectorGUI()
    {
        // color
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(colorProp, new GUIContent("Color"));
        if (EditorGUI.EndChangeCheck())
        {
            foreach (Object obj in serializedObject.targetObjects)
            {
                exSpriteColorController ctrl = obj as exSpriteColorController;
                if (ctrl)
                {
                    ctrl.color = colorProp.colorValue;
                    EditorUtility.SetDirty(ctrl);
                }
            }
        }

        // color Infos
        EditorGUILayout.PropertyField(colorInfosProp, true);

        //
        EditorGUILayout.Space();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Register Colors...", GUILayout.MinWidth(50), GUILayout.Height(20)))
        {
            foreach (Object obj in serializedObject.targetObjects)
            {
                exSpriteColorController ctrl = obj as exSpriteColorController;
                if (ctrl)
                {
                    ctrl.color = Color.white;
                    ctrl.colorInfos.Clear();

                    // register new value
                    ctrl.RegisterAllChildren();

                    EditorUtility.SetDirty(ctrl);
                }
            }
        }
        GUILayout.Space(5);
        GUILayout.EndHorizontal();
    }
Example #2
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public void Init()
    {
        if (inited)
        {
            return;
        }

        panel     = GetComponent <exUIPanel>();
        colorCtrl = GetComponent <exSpriteColorController>();

        if (panel)
        {
            panel.AddEventListener("onStartFadeIn",
                                   delegate(exUIEvent _event) {
                panel.gameObject.SetActive(true);
                if (colorCtrl)
                {
                    colorCtrl.color = new Color(1.0f, 1.0f, 1.0f, 0.0f);
                }
            });
            panel.AddEventListener("onFinishFadeOut",
                                   delegate(exUIEvent _event) {
                panel.gameObject.SetActive(false);
            });
            panel.AddEventListener("onFadeIn",
                                   delegate(exUIEvent _event) {
                exUIRatioEvent ratioEvent = _event as exUIRatioEvent;
                if (colorCtrl)
                {
                    colorCtrl.color = new Color(1.0f, 1.0f, 1.0f, ratioEvent.ratio);
                }
            });
            panel.AddEventListener("onFadeOut",
                                   delegate(exUIEvent _event) {
                exUIRatioEvent ratioEvent = _event as exUIRatioEvent;
                if (colorCtrl)
                {
                    colorCtrl.color = new Color(1.0f, 1.0f, 1.0f, 1.0f - ratioEvent.ratio);
                }
            });
        }

        inited = true;
    }
Example #3
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    public void Init()
    {
        if ( inited )
            return;

        panel = GetComponent<exUIPanel>();
        colorCtrl = GetComponent<exSpriteColorController>();

        if ( panel ) {
            panel.AddEventListener( "onStartFadeIn",
                                    delegate ( exUIEvent _event ) {
                                        panel.gameObject.SetActive(true);
                                        if ( colorCtrl ) {
                                            colorCtrl.color = new Color( 1.0f, 1.0f, 1.0f, 0.0f );
                                        }
                                    } );
            panel.AddEventListener( "onFinishFadeOut",
                                    delegate ( exUIEvent _event ) {
                                        panel.gameObject.SetActive(false);
                                    } );
            panel.AddEventListener( "onFadeIn",
                                    delegate ( exUIEvent _event ) {
                                        exUIRatioEvent ratioEvent = _event as exUIRatioEvent;
                                        if ( colorCtrl ) {
                                            colorCtrl.color = new Color( 1.0f, 1.0f, 1.0f, ratioEvent.ratio );
                                        }
                                    } );
            panel.AddEventListener( "onFadeOut",
                                    delegate ( exUIEvent _event ) {
                                        exUIRatioEvent ratioEvent = _event as exUIRatioEvent;
                                        if ( colorCtrl ) {
                                            colorCtrl.color = new Color( 1.0f, 1.0f, 1.0f, 1.0f-ratioEvent.ratio );
                                        }
                                    } );
        }

        inited = true;
    }