/// <summary>
    /// Draw a list of fields for the specified list of delegates.
    /// </summary>

    static public void DrawEvents(string text, Object undoObject, List <EventDelegate> list, string noTarget, string notValid)
    {
        if (!NGUIEditorTools.DrawHeader(text))
        {
            return;
        }
        NGUIEditorTools.BeginContents();
        EventDelegateEditor.Field(undoObject, list, notValid, notValid);
        NGUIEditorTools.EndContents();
    }
Example #2
0
 void DrawEvents(string key, string text, List <EventDelegate> list, bool minimalistic)
 {
     if (!NGUIEditorTools.DrawHeader(text, key, false, minimalistic))
     {
         return;
     }
     NGUIEditorTools.BeginContents();
     EventDelegateEditor.Field(mTrigger, list, null, null, minimalistic);
     NGUIEditorTools.EndContents();
 }
Example #3
0
    public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
    {
        Undo.RecordObject(prop.serializedObject.targetObject, "Delegate Selection");

        SerializedProperty targetProp = prop.FindPropertyRelative("mTarget");
        SerializedProperty methodProp = prop.FindPropertyRelative("mMethodName");

        MonoBehaviour target     = targetProp.objectReferenceValue as MonoBehaviour;
        string        methodName = methodProp.stringValue;

        EditorGUI.indentLevel = prop.depth;
        EditorGUI.LabelField(position, label);

        Rect line = position;

        line.yMin = position.yMin + lineHeight;
        line.yMax = line.yMin + lineHeight;

        EditorGUI.indentLevel = targetProp.depth;
        target = EditorGUI.ObjectField(line, "Notify", target, typeof(MonoBehaviour), true) as MonoBehaviour;

        if (target != null && target.gameObject != null)
        {
            GameObject   go   = target.gameObject;
            List <Entry> list = EventDelegateEditor.GetMethods(go);

            int index  = 0;
            int choice = 0;

            EventDelegate del = new EventDelegate();
            del.target     = target;
            del.methodName = methodName;
            string[] names = PropertyReferenceDrawer.GetNames(list, del.ToString(), out index);

            line.yMin += lineHeight;
            line.yMax += lineHeight;
            choice     = EditorGUI.Popup(line, "Method", index, names);

            if (choice > 0)
            {
                if (choice != index)
                {
                    Entry entry = list[choice - 1];
                    target     = entry.target as MonoBehaviour;
                    methodName = entry.name;
                }
            }
        }

        targetProp.objectReferenceValue = target;
        methodProp.stringValue          = methodName;
    }
Example #4
0
    public void DrawEvents()
    {
        EventListener script = (EventListener)target;

        if (NGUIEditorTools.DrawHeader("Events"))
        {
            NGUIEditorTools.BeginContents();
            script.clearAfterExecuting = EditorGUILayout.ToggleLeft(" Clear After Executing", script.clearAfterExecuting);
            EditorGUILayout.Space();
            EventDelegateEditor.Field(script.gameObject, script.events);
            NGUIEditorTools.EndContents();
        }
    }
Example #5
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        Trigger trigger = target as Trigger;

        GUILayout.BeginVertical(GUI.skin.box);
        GUILayout.Label("OnEnter");
        EventDelegateEditor.Field(trigger as Object, trigger.onEnter, "", "");
        GUILayout.EndVertical();
        GUILayout.BeginVertical(GUI.skin.box);
        GUILayout.Label("OnExit");
        EventDelegateEditor.Field(trigger as Object, trigger.onExit, "", "");
        GUILayout.EndVertical();
    }
Example #6
0
 public static void DrawEvents(string name, List <EventDelegate> evts, Object undoObject)
 {
     if (!CaomaoEditorTools.DrawHead(name, name))
     {
         return;
     }
     CaomaoEditorTools.BeginContents();
     GUILayout.BeginHorizontal();
     GUILayout.BeginVertical();
     EventDelegateEditor.Field(evts, undoObject);
     GUILayout.EndVertical();
     GUILayout.EndHorizontal();
     CaomaoEditorTools.EndContents();
 }
Example #7
0
    /// <summary>
    /// Draw a list of fields for the specified list of delegates.
    /// </summary>

    static public void DrawActions(string text, string key, Object undoObject, ref float distance, List <EventDelegate> list, string noTarget, string notValid)
    {
        if (!UIEditorTools.DrawHeader(text, key))
        {
            return;
        }

        UIEditorTools.BeginContents();
        GUILayout.Space(5);
        distance = EditorGUILayout.FloatField("Trigger Dist", distance);
        GUILayout.Space(5);
        EventDelegateEditor.Field(undoObject, list, notValid, notValid);
        GUILayout.Space(5);
        UIEditorTools.EndContents();
    }
Example #8
0
    /// <summary>
    /// Draw a list of fields for the specified list of delegates.
    /// </summary>

    static public void DrawActions(string text, string key, Object undoObject, ref Collider collider, List <EventDelegate> list, string noTarget, string notValid)
    {
        if (!UIEditorTools.DrawHeader(text, key))
        {
            return;
        }

        UIEditorTools.BeginContents();
        GUILayout.Space(5);
        collider = EditorGUILayout.ObjectField("Trigger Rgn", collider, typeof(Collider), true) as Collider;
        GUILayout.Space(5);
        EventDelegateEditor.Field(undoObject, list, notValid, notValid);
        GUILayout.Space(5);
        UIEditorTools.EndContents();
    }
    /// <summary>
    /// 绘制委托事件
    /// </summary>

    static public void DrawEvents(string text, Object undoObject, List <EventDelegate> list, string noTarget, string notValid)
    {
        if (!CustomUITweenEditorTools.DrawHeader(text, text, false))
        {
            return;
        }


        CustomUITweenEditorTools.BeginContents();
        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical();

        EventDelegateEditor.Field(undoObject, list, notValid, notValid);

        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
        CustomUITweenEditorTools.EndContents();
    }
Example #10
0
    /// <summary>
    /// Draw a list of fields for the specified list of delegates.
    /// </summary>

    static public void DrawEvents(string text, Object undoObject, List <EventDelegate> list, string noTarget, string notValid, bool minimalistic)
    {
        if (!NGUIEditorTools.DrawHeader(text, text, false, minimalistic))
        {
            return;
        }

        if (!minimalistic)
        {
            NGUIEditorTools.BeginContents(minimalistic);
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();

            EventDelegateEditor.Field(undoObject, list, notValid, notValid, minimalistic);

            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            NGUIEditorTools.EndContents();
        }
        else
        {
            EventDelegateEditor.Field(undoObject, list, notValid, notValid, minimalistic);
        }
    }
    public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
    {
        Undo.RecordObject(prop.serializedObject.targetObject, "Delegate Selection");

        SerializedProperty targetProp = prop.FindPropertyRelative("mTarget");
        SerializedProperty methodProp = prop.FindPropertyRelative("mMethodName");

        MonoBehaviour target     = targetProp.objectReferenceValue as MonoBehaviour;
        string        methodName = methodProp.stringValue;

        EditorGUI.indentLevel = prop.depth;
        EditorGUI.LabelField(rect, label);

        Rect lineRect = rect;

        lineRect.yMin = rect.yMin + lineHeight;
        lineRect.yMax = lineRect.yMin + lineHeight;

        EditorGUI.indentLevel = targetProp.depth;
        target = EditorGUI.ObjectField(lineRect, "Notify", target, typeof(MonoBehaviour), true) as MonoBehaviour;
        targetProp.objectReferenceValue = target;

        if (target != null && target.gameObject != null)
        {
            GameObject   go   = target.gameObject;
            List <Entry> list = EventDelegateEditor.GetMethods(go);

            int index  = 0;
            int choice = 0;

            EventDelegate del = new EventDelegate();
            del.target     = target;
            del.methodName = methodName;
            string[] names = PropertyReferenceDrawer.GetNames(list, del.ToString(), out index);

            lineRect.yMin += lineHeight;
            lineRect.yMax += lineHeight;
            choice         = EditorGUI.Popup(lineRect, "Method", index, names);

            if (choice > 0 && choice != index)
            {
                Entry entry = list[choice - 1];
                target     = entry.target as MonoBehaviour;
                methodName = entry.name;
                targetProp.objectReferenceValue = target;
                methodProp.stringValue          = methodName;
            }

            SerializedProperty        paramArrayProp = prop.FindPropertyRelative("mParameters");
            EventDelegate.Parameter[] ps             = del.parameters;

            if (ps != null)
            {
                paramArrayProp.arraySize = ps.Length;
                for (int i = 0; i < ps.Length; i++)
                {
                    EventDelegate.Parameter param     = ps[i];
                    SerializedProperty      paramProp = paramArrayProp.GetArrayElementAtIndex(i);
                    SerializedProperty      objProp   = paramProp.FindPropertyRelative("obj");
                    SerializedProperty      fieldProp = paramProp.FindPropertyRelative("field");

                    param.obj   = objProp.objectReferenceValue;
                    param.field = fieldProp.stringValue;
                    Object obj = param.obj;

                    lineRect.yMin += lineHeight;
                    lineRect.yMax += lineHeight;

                    obj = EditorGUI.ObjectField(lineRect, "   Arg " + i, obj, typeof(Object), true);

                    objProp.objectReferenceValue = obj;
                    del.parameters[i].obj        = obj;
                    param.obj = obj;

                    if (obj == null)
                    {
                        continue;
                    }

                    GameObject  selGO = null;
                    System.Type type  = param.obj.GetType();
                    if (type == typeof(GameObject))
                    {
                        selGO = param.obj as GameObject;
                    }
                    else if (type.IsSubclassOf(typeof(Component)))
                    {
                        selGO = (param.obj as Component).gameObject;
                    }

                    if (selGO != null)
                    {
                        // Parameters must be exact -- they can't be converted like property bindings
                        PropertyReferenceDrawer.filter     = param.expectedType;
                        PropertyReferenceDrawer.canConvert = false;
                        List <PropertyReferenceDrawer.Entry> ents = PropertyReferenceDrawer.GetProperties(selGO, true, false);

                        int      selection;
                        string[] props = EventDelegateEditor.GetNames(ents, EditorTool.GetFuncName(param.obj, param.field), out selection);

                        lineRect.yMin += lineHeight;
                        lineRect.yMax += lineHeight;
                        int newSel = EditorGUI.Popup(lineRect, " ", selection, props);

                        if (newSel != selection)
                        {
                            if (newSel == 0)
                            {
                                param.obj   = selGO;
                                param.field = null;

                                objProp.objectReferenceValue = selGO;
                                fieldProp.stringValue        = null;
                            }
                            else
                            {
                                param.obj   = ents[newSel - 1].target;
                                param.field = ents[newSel - 1].name;

                                objProp.objectReferenceValue = param.obj;
                                fieldProp.stringValue        = param.field;
                            }
                        }
                    }
                    else if (!string.IsNullOrEmpty(param.field))
                    {
                        param.field = null;
                    }

                    PropertyReferenceDrawer.filter     = typeof(void);
                    PropertyReferenceDrawer.canConvert = true;
                }
            }
        }
    }
Example #12
0
    public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
    {
        Undo.RecordObject(prop.serializedObject.targetObject, "Delegate Selection");

        SerializedProperty targetProp = prop.FindPropertyRelative("mTarget");
        SerializedProperty methodProp = prop.FindPropertyRelative("mMethodName");

        MonoBehaviour target     = targetProp.objectReferenceValue as MonoBehaviour;
        string        methodName = methodProp.stringValue;

        EditorGUI.indentLevel = prop.depth;
        EditorGUI.LabelField(rect, label);

        Rect lineRect = rect;

        lineRect.yMin = rect.yMin + lineHeight;
        lineRect.yMax = lineRect.yMin + lineHeight;

        EditorGUI.indentLevel = targetProp.depth;
        target = EditorGUI.ObjectField(lineRect, "Notify", target, typeof(MonoBehaviour), true) as MonoBehaviour;
        targetProp.objectReferenceValue = target;

        if (target != null && target.gameObject != null)
        {
            GameObject   go   = target.gameObject;
            List <Entry> list = EventDelegateEditor.GetMethods(go);

            int index  = 0;
            int choice = 0;

            EventDelegate del = new EventDelegate();
            del.target     = target;
            del.methodName = methodName;
            string[] names = PropertyReferenceDrawer.GetNames(list, del.ToString(), out index);

            lineRect.yMin += lineHeight;
            lineRect.yMax += lineHeight;
            choice         = EditorGUI.Popup(lineRect, "Method", index, names);

            if (choice > 0)
            {
                if (choice != index)
                {
                    Entry entry = list[choice - 1];
                    target     = entry.target as MonoBehaviour;
                    methodName = entry.name;
                    targetProp.objectReferenceValue = target;
                    methodProp.stringValue          = methodName;
                }
            }

            // Unfortunately Unity's property drawers only work with UnityEngine.Object-derived types.
            // This means that arrays are not supported. And since EventDelegate is not derived from
            // UnityEngine.Object either, it means that it's not possible to modify the parameter array.
            EditorGUI.BeginDisabledGroup(true);

            //SerializedProperty paramProp = prop.FindPropertyRelative("mParameters");
            EventDelegate.Parameter[] ps = del.parameters;

            if (ps != null)
            {
                for (int i = 0; i < ps.Length; ++i)
                {
                    EventDelegate.Parameter param = ps[i];
                    lineRect.yMin += lineHeight;
                    lineRect.yMax += lineHeight;
                    param.obj      = EditorGUI.ObjectField(lineRect, "   Arg " + i, param.obj, typeof(Object), true);
                    if (param.obj == null)
                    {
                        continue;
                    }

                    GameObject  selGO = null;
                    System.Type type  = param.obj.GetType();
                    if (type == typeof(GameObject))
                    {
                        selGO = param.obj as GameObject;
                    }
                    else if (type.IsSubclassOf(typeof(Component)))
                    {
                        selGO = (param.obj as Component).gameObject;
                    }

                    if (selGO != null)
                    {
                        // Parameters must be exact -- they can't be converted like property bindings
                        PropertyReferenceDrawer.filter     = param.expectedType;
                        PropertyReferenceDrawer.canConvert = false;
                        List <PropertyReferenceDrawer.Entry> ents = PropertyReferenceDrawer.GetProperties(selGO, true, false);

                        int      selection;
                        string[] props = EventDelegateEditor.GetNames(ents, NGUITools.GetFuncName(param.obj, param.field), out selection);

                        lineRect.yMin += lineHeight;
                        lineRect.yMax += lineHeight;
                        int newSel = EditorGUI.Popup(lineRect, " ", selection, props);

                        if (newSel != selection)
                        {
                            if (newSel == 0)
                            {
                                param.obj   = selGO;
                                param.field = null;
                            }
                            else
                            {
                                param.obj   = ents[newSel - 1].target;
                                param.field = ents[newSel - 1].name;
                            }
                        }
                    }
                    else if (!string.IsNullOrEmpty(param.field))
                    {
                        param.field = null;
                    }

                    PropertyReferenceDrawer.filter     = typeof(void);
                    PropertyReferenceDrawer.canConvert = true;
                }
            }

            EditorGUI.EndDisabledGroup();
        }
        //else paramProp.objectReferenceValue = null;
    }
Example #13
0
    // ========================================================================== //

    /* public - [Do] Function
     * 외부 객체가 호출                         */

    /* public - [Event] Function
     * 프랜드 객체가 호출                       */

    // ========================================================================== //

    /* protected - [abstract & virtual]         */

    /* protected - [Event] Function
     * 자식 객체가 호출                         */

    /* protected - Override & Unity API         */
    public override void OnInspectorGUI()
    {
        //base.OnInspectorGUI();

        _pTarget = target as CUIButtonMultiToggle;
        _pAtlas  = _pTarget.GetComponent <UISprite>().atlas;

        if (_pTarget.listEvent == null)
        {
            _pTarget.listEvent = new List <CUIButtonMultiToggle.SButtonToggle>();
        }

        _iOriginStateCount = _pTarget.listEvent.Count;
        _iOriginStateCount = EditorGUILayout.IntField("상태 개수", _iOriginStateCount);

        if (_pTarget.listEvent == null)
        {
            _pTarget.listEvent = new List <CUIButtonMultiToggle.SButtonToggle>();
        }

        if (_pAtlas == null)
        {
            Debug.LogWarning("UI Sprite의 Atlas가 세팅되지 않았습니다..", _pTarget);
            return;
        }

        if (_iOriginStateCount != _pTarget.listEvent.Count)
        {
            if (_iOriginStateCount < _pTarget.listEvent.Count)
            {
                int iLoopCount = _pTarget.listEvent.Count - _iOriginStateCount;
                try
                {
                    for (int i = 0; i < iLoopCount; i++)
                    {
                        _pTarget.listEvent.Remove(_pTarget.listEvent[i]);
                    }
                }
                catch (System.Exception e)
                {
                    Debug.LogWarning(e);
                }
            }
            else
            {
                int iLoopCount = _iOriginStateCount - _pTarget.listEvent.Count;
                for (int i = 0; i < iLoopCount; i++)
                {
                    _pTarget.listEvent.Add(new CUIButtonMultiToggle.SButtonToggle());
                }
            }
        }

        if (_iOriginStateCount != 0)
        {
            _pTarget.iDefaultState = EditorGUILayout.IntField(string.Format("기본 상태 1 ~ {0}", _pTarget.listEvent.Count), _pTarget.iDefaultState);
        }
        if (_pTarget.iDefaultState > _pTarget.listEvent.Count || _pTarget.iDefaultState <= 0)
        {
            Debug.LogError("상태개수 범위안의 숫자를 선택해 주십시오.");
        }

        _pTarget._eButtonToggleOption = (CUIButtonMultiToggle.EButtonToggleOption)EditorGUILayout.EnumPopup("옵션선택", _pTarget._eButtonToggleOption);

        for (int i = 0; i < _pTarget.listEvent.Count; i++)
        {
            CUIButtonMultiToggle.SButtonToggle sToggle = _pTarget.listEvent[i];
            //NGUIEditorTools.DrawEvents("On StateChange", _pTarget, sToggle.listEvent, false);

            if (NGUIEditorTools.DrawHeader(string.Format("OnChangeState_{0}", i + 1)) == false)
            {
                continue;
            }

            if (_pTarget.listEvent[i].listEvent == null)
            {
                _pTarget.listEvent[i].listEvent = new List <EventDelegate>();
            }

            EventDelegateEditor.Field(_pTarget, _pTarget.listEvent[i].listEvent, false);
            // 여기서 필요한 로직만 가져옴
            //NGUIEditorTools.DrawAdvancedSpriteField(_pAtlas, sToggle.strSpriteName, SelectSprite, false);
            GUILayout.BeginHorizontal();
            {
                if (NGUIEditorTools.DrawPrefixButton("Sprite"))
                {
                    NGUISettings.atlas          = _pAtlas;
                    NGUISettings.selectedSprite = sToggle.strSpriteName;
                    SpriteSelector.Show(SelectSprite);
                    _iCurrentEditItemIndex = i;
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label(sToggle.strSpriteName, "HelpBox", GUILayout.Height(18f));
                NGUIEditorTools.DrawPadding();
                GUILayout.EndHorizontal();
            }
            GUILayout.EndHorizontal();
        }
    }