Exemple #1
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public void AddEffect_Offset(exSpriteBase _target, EffectEventType _type, exEase.Type _curveType, Vector2 _to, float _duration)
    {
        exUIControl ctrl = GetComponent <exUIControl>();

        if (ctrl)
        {
            EffectInfo_Offset info = new EffectInfo_Offset();
            info.duration  = _duration;
            info.target    = _target;
            info.normal    = _target.offset;
            info.curveType = _curveType;

            EffectInfo_Offset.PropInfo propInfo = new EffectInfo_Offset.PropInfo();
            propInfo.type = _type;
            propInfo.val  = _to;
            info.propInfos.Add(propInfo);

            EffectState_Offset state = new EffectState_Offset();
            state.info = info;
            state.func = info.GetCurveFunction();
            AddState_Offset(ctrl, state);
        }
    }
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    protected void OffsetInfoField(List <EffectInfo_Offset> _infos)
    {
        GUILayout.BeginHorizontal();
        GUILayout.Space(4f);

        GUILayout.BeginVertical();
        // name
        GUILayout.Toggle(true, "Offset", "dragtab");

        EditorGUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(10f));
        GUILayout.BeginVertical();

        // infos
        for (int i = 0; i < _infos.Count; ++i)
        {
            bool infoDeleted       = false;
            EffectInfo_Offset info = _infos[i];

            // target
            EditorGUILayout.BeginHorizontal();

            // receiver
            EditorGUI.BeginChangeCheck();
            info.target = EditorGUILayout.ObjectField(info.target, typeof(exSpriteBase), true) as exSpriteBase;
            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(target);
            }

            //
            if (info.target != null)
            {
            }
            else
            {
                infoDeleted = true;
            }

            // Delete
            if (GUILayout.Button(styles.iconToolbarMinus, "InvisibleButton", GUILayout.Width(20f)))
            {
                infoDeleted = true;
            }
            GUILayout.Space(3f);

            EditorGUILayout.EndHorizontal();

            // curve, duration
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(30);
            EditorGUI.BeginChangeCheck();
            GUILayout.Label("Custom Curve");
            info.customCurve = EditorGUILayout.Toggle(info.customCurve, GUILayout.Width(15));
            if (info.customCurve)
            {
                info.curve = EditorGUILayout.CurveField(info.curve);
            }
            else
            {
                info.curveType = (exEase.Type)EditorGUILayout.EnumPopup(info.curveType);
            }
            info.duration = EditorGUILayout.FloatField(info.duration);

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(target);
            }
            EditorGUILayout.EndHorizontal();

            float x = 0.0f;
            float y = 0.0f;

            // normal
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(30);
            if (GUILayout.Button("Sync", GUILayout.Width(50)))
            {
                info.normal = info.target.offset;
                EditorUtility.SetDirty(target);
            }

            EditorGUI.BeginChangeCheck();

            GUILayout.Label("Normal");

            GUILayout.Label("X", GUILayout.Width(10));
            x = EditorGUILayout.FloatField("", info.normal.x, GUILayout.Width(30));
            GUILayout.Label("Y", GUILayout.Width(10));
            y = EditorGUILayout.FloatField("", info.normal.y, GUILayout.Width(30));
            if (EditorGUI.EndChangeCheck())
            {
                info.normal = new Vector2(x, y);
                EditorUtility.SetDirty(target);
            }
            EditorGUILayout.EndHorizontal();

            // Properties
            for (int j = 0; j < info.propInfos.Count; ++j)
            {
                EffectInfo_Offset.PropInfo propInfo = info.propInfos[j];

                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(30);
                // propInfoDeleted
                bool propInfoDeleted = false;
                if (GUILayout.Button(styles.iconToolbarMinus,
                                     "InvisibleButton",
                                     GUILayout.Width(styles.iconToolbarMinus.width),
                                     GUILayout.Height(styles.iconToolbarMinus.height)))
                {
                    propInfoDeleted = true;
                }

                EditorGUI.BeginChangeCheck();

                GUILayout.Label(System.Enum.GetName(typeof(EffectEventType), propInfo.type));
                GUILayout.Label("X", GUILayout.Width(10));
                x = EditorGUILayout.FloatField("", propInfo.val.x, GUILayout.Width(30));
                GUILayout.Label("Y", GUILayout.Width(10));
                y = EditorGUILayout.FloatField("", propInfo.val.y, GUILayout.Width(30));

                if (EditorGUI.EndChangeCheck())
                {
                    propInfo.val = new Vector2(x, y);
                    EditorUtility.SetDirty(target);
                }

                if (propInfoDeleted)
                {
                    info.propInfos.RemoveAt(j);
                    --j;
                    EditorUtility.SetDirty(target);
                }

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
            }

            // Add Property
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            List <string> eventNameList = new List <string>();
            eventNameList.Add("Add Property");
            eventNameList.AddRange(System.Enum.GetNames(typeof(EffectEventType)));

            foreach (EffectInfo_Offset.PropInfo propInfo in info.propInfos)
            {
                int idx = eventNameList.IndexOf(System.Enum.GetName(typeof(EffectEventType), propInfo.type));
                if (idx != -1)
                {
                    eventNameList.RemoveAt(idx);
                }
            }

            int choice = EditorGUILayout.Popup(0, eventNameList.ToArray(), GUILayout.Width(100));
            if (choice != 0)
            {
                EffectInfo_Offset.PropInfo propInfo = new EffectInfo_Offset.PropInfo();
                propInfo.type = (EffectEventType)System.Enum.Parse(typeof(EffectEventType), eventNameList[choice]);
                propInfo.val  = info.normal;
                info.propInfos.Add(propInfo);
                EditorUtility.SetDirty(target);
            }
            EditorGUILayout.EndHorizontal();

            //
            if (infoDeleted)
            {
                _infos.RemoveAt(i);
                --i;
                EditorUtility.SetDirty(target);
            }
        }

        // new slot
        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        exSpriteBase receiver = EditorGUILayout.ObjectField(null, typeof(exSpriteBase), true, GUILayout.Width(150)) as exSpriteBase;

        if (receiver != null)
        {
            EffectInfo_Offset info = new EffectInfo_Offset();
            info.target = receiver;

            _infos.Add(info);
            EditorUtility.SetDirty(target);
        }
        GUILayout.Label(styles.iconToolbarPlus, GUILayout.Width(20));
        EditorGUILayout.EndHorizontal();

        GUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();

        GUILayout.EndVertical();

        GUILayout.Space(4f);
        GUILayout.EndHorizontal();
    }
Exemple #3
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    void AddState_Offset(exUIControl _ctrl, EffectState_Offset _state)
    {
        for (int i = 0; i < _state.info.propInfos.Count; ++i)
        {
            EffectInfo_Offset.PropInfo propInfo = _state.info.propInfos[i];
            switch (propInfo.type)
            {
            case EffectEventType.Deactive:
                _ctrl.AddEventListener("onDeactive",
                                       delegate(exUIEvent _event) {
                    enabled = true;
                    _state.Begin(propInfo.val);
                });
                _ctrl.AddEventListener("onActive",
                                       delegate(exUIEvent _event) {
                    enabled = true;
                    _state.Begin(_state.info.normal);
                });
                break;

            case EffectEventType.Press:
                _ctrl.AddEventListener("onPressDown",
                                       delegate(exUIEvent _event) {
                    enabled = true;
                    _state.Begin(propInfo.val);
                });
                _ctrl.AddEventListener("onPressUp",
                                       delegate(exUIEvent _event) {
                    enabled = true;
                    _state.Begin(_state.info.GetValue(EffectEventType.Hover));
                });
                break;

            case EffectEventType.Hover:
                _ctrl.AddEventListener("onHoverIn",
                                       delegate(exUIEvent _event) {
                    enabled = true;
                    _state.Begin(propInfo.val);
                });
                _ctrl.AddEventListener("onHoverOut",
                                       delegate(exUIEvent _event) {
                    enabled = true;
                    _state.Begin(_state.info.normal);
                });
                break;

            case EffectEventType.Unchecked:
                exUIToggle toggle = _ctrl as exUIToggle;
                if (toggle != null)
                {
                    _ctrl.AddEventListener("onUnchecked",
                                           delegate(exUIEvent _event) {
                        enabled = true;
                        _state.Begin(propInfo.val);
                    });
                    _ctrl.AddEventListener("onChecked",
                                           delegate(exUIEvent _event) {
                        enabled = true;
                        _state.Begin(_state.info.GetValue(EffectEventType.Hover));
                    });
                }
                break;
            }
        }

        states.Add(_state);
    }
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    protected void OffsetInfoField( List<EffectInfo_Offset> _infos )
    {
        GUILayout.BeginHorizontal();
        GUILayout.Space(4f);

            GUILayout.BeginVertical();
                // name
                GUILayout.Toggle( true, "Offset", "dragtab");

                EditorGUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(10f));
                GUILayout.BeginVertical();

                    // infos
                    for ( int i = 0; i < _infos.Count; ++i ) {
                        bool infoDeleted = false;
                        EffectInfo_Offset info = _infos[i];

                        // target
                        EditorGUILayout.BeginHorizontal();

                            // receiver
                            EditorGUI.BeginChangeCheck();
                            info.target = EditorGUILayout.ObjectField( info.target, typeof(exSpriteBase), true ) as exSpriteBase;
                            if ( EditorGUI.EndChangeCheck() ) {
                                EditorUtility.SetDirty(target);
                            }

                            //
                            if ( info.target != null ) {
                            }
                            else {
                                infoDeleted = true;
                            }

                            // Delete
                            if ( GUILayout.Button( styles.iconToolbarMinus, "InvisibleButton", GUILayout.Width(20f) ) ) {
                                infoDeleted = true;
                            }
                            GUILayout.Space(3f);

                        EditorGUILayout.EndHorizontal();

                        // curve, duration
                        EditorGUILayout.BeginHorizontal();
                            GUILayout.Space(30);
                            EditorGUI.BeginChangeCheck();
                                GUILayout.Label("Custom Curve");
                                info.customCurve = EditorGUILayout.Toggle(info.customCurve,GUILayout.Width(15));
                                if ( info.customCurve ) {
                                    info.curve = EditorGUILayout.CurveField(info.curve);
                                }
                                else {
                                    info.curveType = (exEase.Type)EditorGUILayout.EnumPopup(info.curveType);
                                }
                                info.duration = EditorGUILayout.FloatField(info.duration);

                            if ( EditorGUI.EndChangeCheck() ) {
                                EditorUtility.SetDirty(target);
                            }
                        EditorGUILayout.EndHorizontal();

                        float x = 0.0f;
                        float y = 0.0f;

                        // normal
                        EditorGUILayout.BeginHorizontal();
                            GUILayout.Space(30);
                            if ( GUILayout.Button("Sync", GUILayout.Width(50)) ) {
                                info.normal = info.target.offset;
                                EditorUtility.SetDirty(target);
                            }

                            EditorGUI.BeginChangeCheck();

                                GUILayout.Label("Normal");

                                GUILayout.Label("X", GUILayout.Width(10));
                                x = EditorGUILayout.FloatField("",info.normal.x,GUILayout.Width(30));
                                GUILayout.Label("Y", GUILayout.Width(10));
                                y = EditorGUILayout.FloatField("",info.normal.y,GUILayout.Width(30));
                            if ( EditorGUI.EndChangeCheck() ) {
                                info.normal = new Vector2( x, y );
                                EditorUtility.SetDirty(target);
                            }
                        EditorGUILayout.EndHorizontal();

                        // Properties
                        for ( int j = 0; j < info.propInfos.Count; ++j ) {
                            EffectInfo_Offset.PropInfo propInfo = info.propInfos[j];

                            EditorGUILayout.BeginHorizontal();
                                GUILayout.Space(30);
                                // propInfoDeleted
                                bool propInfoDeleted = false;
                                if ( GUILayout.Button( styles.iconToolbarMinus,
                                                       "InvisibleButton",
                                                       GUILayout.Width(styles.iconToolbarMinus.width),
                                                       GUILayout.Height(styles.iconToolbarMinus.height) ) )
                                {
                                    propInfoDeleted = true;
                                }

                                EditorGUI.BeginChangeCheck();

                                    GUILayout.Label(System.Enum.GetName( typeof(EffectEventType), propInfo.type ));
                                    GUILayout.Label("X", GUILayout.Width(10));
                                    x = EditorGUILayout.FloatField("",propInfo.val.x,GUILayout.Width(30));
                                    GUILayout.Label("Y", GUILayout.Width(10));
                                    y = EditorGUILayout.FloatField("",propInfo.val.y,GUILayout.Width(30));

                                if ( EditorGUI.EndChangeCheck() ) {
                                    propInfo.val = new Vector2(x,y);
                                    EditorUtility.SetDirty(target);
                                }

                                if ( propInfoDeleted ) {
                                    info.propInfos.RemoveAt(j);
                                    --j;
                                    EditorUtility.SetDirty(target);
                                }

                            EditorGUILayout.EndHorizontal();
                            EditorGUILayout.Space();
                        }

                        // Add Property
                        EditorGUILayout.BeginHorizontal();
                            GUILayout.FlexibleSpace();
                            List<string> eventNameList = new List<string>();
                            eventNameList.Add( "Add Property" );
                            eventNameList.AddRange( System.Enum.GetNames(typeof(EffectEventType)) );

                            foreach ( EffectInfo_Offset.PropInfo propInfo in info.propInfos ) {
                                int idx = eventNameList.IndexOf( System.Enum.GetName( typeof(EffectEventType), propInfo.type )  );
                                if ( idx != -1 ) {
                                    eventNameList.RemoveAt(idx);
                                }
                            }

                            int choice = EditorGUILayout.Popup ( 0, eventNameList.ToArray(), GUILayout.Width(100) );
                            if ( choice != 0 ) {
                                EffectInfo_Offset.PropInfo propInfo = new EffectInfo_Offset.PropInfo();
                                propInfo.type = (EffectEventType)System.Enum.Parse(typeof(EffectEventType), eventNameList[choice]);
                                propInfo.val = info.normal;
                                info.propInfos.Add(propInfo);
                                EditorUtility.SetDirty(target);
                            }
                        EditorGUILayout.EndHorizontal();

                        //
                        if ( infoDeleted ) {
                            _infos.RemoveAt(i);
                            --i;
                            EditorUtility.SetDirty(target);
                        }
                    }

                    // new slot
                    EditorGUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        exSpriteBase receiver = EditorGUILayout.ObjectField( null, typeof(exSpriteBase), true, GUILayout.Width(150) ) as exSpriteBase;
                        if ( receiver != null ) {

                            EffectInfo_Offset info = new EffectInfo_Offset();
                            info.target = receiver;

                            _infos.Add(info);
                            EditorUtility.SetDirty(target);
                        }
                        GUILayout.Label( styles.iconToolbarPlus, GUILayout.Width(20) );
                    EditorGUILayout.EndHorizontal();

                GUILayout.EndVertical();
                EditorGUILayout.EndHorizontal();

            GUILayout.EndVertical();

        GUILayout.Space(4f);
        GUILayout.EndHorizontal();
    }
Exemple #5
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------
    public void AddEffect_Offset( exSpriteBase _target, EffectEventType _type, exEase.Type _curveType, Vector2 _to, float _duration )
    {
        exUIControl ctrl = GetComponent<exUIControl>();
        if ( ctrl ) {
            EffectInfo_Offset info = new EffectInfo_Offset();
            info.duration = _duration;
            info.target = _target;
            info.normal = _target.offset;
            info.curveType = _curveType;

            EffectInfo_Offset.PropInfo propInfo = new EffectInfo_Offset.PropInfo();
            propInfo.type = _type;
            propInfo.val = _to;
            info.propInfos.Add(propInfo);

            EffectState_Offset state = new EffectState_Offset();
            state.info = info;
            state.func = info.GetCurveFunction();
            AddState_Offset( ctrl, state );
        }
    }