public void Render()
        {
            GUI.backgroundColor = ColorMixer.FromHex(0x335fd8).ToColor();

            GUI.backgroundColor = Color.white;

            EditorGUILayout.BeginHorizontal(StyleCache.Instance.Toolbar, GUILayout.Height(35));

            EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true));

            GUILayout.FlexibleSpace();
            GUILayout.Label(GuiContentCache.Instance.Search, StyleCache.Instance.Label); //EditorStyles.largeLabel);

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true));
            GUILayout.FlexibleSpace();

            _newSearchText = GUILayout.TextField(_searchText, GUILayout.Width(200) /*, GUILayout.Height(30), */);
            if (_newSearchText != _searchText)
            {
                _searchText = _newSearchText;
                _changed    = true;
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();

            if (!string.IsNullOrEmpty(_searchText))
            {
                EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true));
                GUILayout.FlexibleSpace();

                if (GUILayout.Button(TextureCache.Instance.Cancel, StyleCache.Instance.SmallOpenButton, GUILayout.ExpandWidth(false)))
                {
                    _searchText = string.Empty;
                    _changed    = true;
                }

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndVertical();
            }

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();

            //if (EditorSettings.ShowControls)
            //{
            EditorGUILayout.BeginVertical(StyleCache.Instance.ScrollviewBackground, GUILayout.ExpandWidth(true));
            // panel content

            if (AddEventHandlerDialog.Instance.ShowHelp)
            {
                EditorGUILayout.HelpBox(Help.EventHandlerList, MessageType.Info, true);
            }

            GUILayout.Space(1);

            _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition, GUILayout.ExpandHeight(true));

            if (_contents.Length == 0)
            {
                GUILayout.Label(GuiContentCache.Instance.NoEventHandlersFound, StyleCache.Instance.CenteredLabel, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            }
            else
            {
                _newIndex = GUILayout.SelectionGrid(_selectedIndex, _contents, 1,
                                                    StyleCache.Instance.GridButton,
                                                    GUILayout.ExpandWidth(true));

                if (_selectedIndex != _newIndex)
                {
                    _selectedIndex = _newIndex;
                    var descriptor = _descriptors[_selectedIndex];
                    AddEventHandlerDialog.Instance.Data.ClassName  = descriptor.ScriptName;
                    AddEventHandlerDialog.Instance.Data.MethodName = descriptor.Name;
                    //Debug.Log("AddEventHandlerDialog.Instance.Data.MethodName set to: " + AddEventHandlerDialog.Instance.Data.MethodName);

                    GotoSignal.Emit(1);
                    //AddEventHandlerDialog.Instance.Repaint();
                }
            }

            EditorGUILayout.EndScrollView();

            GUILayout.Space(2);

            EditorGUILayout.EndVertical();  // panel chrome

            GUILayout.Space(1);

            if (_changed)
            {
                _changed = false;
                Process();
            }
        }
Esempio n. 2
0
        public void Render()
        {
            //GUILayout.Space(-5);

            if (AddEventHandlerDialog.Instance.ShowHelp)
            {
                EditorGUILayout.HelpBox(Help.EventList, MessageType.Info, true);
            }

            /**
             * Toggle buttons (mode switch)
             * */
            EditorGUILayout.BeginHorizontal(StyleCache.Instance.Toolbar, GUILayout.Height(35));

            _oldEnabled = GUI.enabled;
            GUI.enabled = _allowBubbling && !_inputMode;

            _selected = GUILayout.Toggle(_targetMode, new GUIContent("Target", _targetMode ? TextureCache.Instance.EventPhaseTargetOn : TextureCache.Instance.EventPhaseTarget), StyleCache.Instance.Toggle, GUILayout.Height(30), GUILayout.ExpandWidth(false));
            if (_selected != _targetMode)
            {
                _targetMode = _selected;
                _changed    = true;
            }

            _selected = GUILayout.Toggle(_bubblingMode, new GUIContent("Bubbling", _bubblingMode ? TextureCache.Instance.EventPhaseBubblingOn : TextureCache.Instance.EventPhaseBubbling), StyleCache.Instance.Toggle, GUILayout.Height(30), GUILayout.ExpandWidth(false));
            if (_selected != _bubblingMode)
            {
                _bubblingMode = _selected;
                _changed      = true;
            }
            GUI.enabled = _oldEnabled;

            /**
             * Search box
             * */
            _oldEnabled = GUI.enabled;
            GUI.enabled = !_inputMode;

            EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true));
            GUILayout.FlexibleSpace();

            GUILayout.Label(GuiContentCache.Instance.Search, StyleCache.Instance.Label);

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(false));
            GUILayout.FlexibleSpace();

            if (!_inputMode)
            {
                GUI.SetNextControlName(InputTextFocusId);
            }
            _newSearchText = GUILayout.TextField(_searchText, GUILayout.Width(200) /*, GUILayout.Height(30), */);
            if (!_inputMode)
            {
                GUI.FocusControl(InputTextFocusId);
            }

            if (_newSearchText != _searchText)
            {
                _searchText = _newSearchText;
                _changed    = true;
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();

            /**
             * Reset button
             * */
            if (!string.IsNullOrEmpty(_searchText))
            {
                EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(false));
                GUILayout.FlexibleSpace();

                if (GUILayout.Button(TextureCache.Instance.Cancel, StyleCache.Instance.SmallOpenButton, GUILayout.ExpandWidth(false)))
                {
                    _searchText = string.Empty;
                    _changed    = true;
                }

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndVertical();
            }

            GUI.enabled = _oldEnabled;

            GUILayout.FlexibleSpace();

            /**
             * Input mode button
             * */
            _selected = GUILayout.Toggle(_inputMode, new GUIContent("Input mode", _inputMode ? TextureCache.Instance.InputModeOn : TextureCache.Instance.InputMode), StyleCache.Instance.Toggle, GUILayout.Height(30), GUILayout.ExpandWidth(false));
            if (_selected != _inputMode)
            {
                _inputMode = _selected;
                _changed   = true;

                if (_selectedIndex > -1 && _selectedIndex < _strEvents.Length)
                {
                    _inputText = _strEvents[_selectedIndex - 1];
                }

                EditorSettings.AddEventHandlerInputMode = _inputMode;
            }

            if (_changed)
            {
                _changed = false;
                Process();
            }

            EditorGUILayout.EndHorizontal();

            GUI.backgroundColor = ColorMixer.FromHex(0x335fd8).ToColor();

            GUI.backgroundColor = Color.white;

//            EditorGUILayout.BeginHorizontal();
//
//            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginVertical(StyleCache.Instance.ScrollviewBackground, GUILayout.ExpandWidth(true));

            if (_inputMode)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true));
                GUILayout.FlexibleSpace();

                GUILayout.Label("Event name: ", EditorStyles.largeLabel);

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(false));
                GUILayout.FlexibleSpace();

                GUI.SetNextControlName(InputTextFocusId);
                _newInputText = GUILayout.TextField(_inputText, GUILayout.Width(200) /*, GUILayout.Height(30), */);
                GUI.FocusControl(InputTextFocusId);

                if (_newInputText != _inputText)
                {
                    _inputText = _newInputText;
                    _changed   = true;
                    AddEventHandlerDialog.Instance.Data.EventAttribute = null;
                    AddEventHandlerDialog.Instance.Data.EventName      = _inputText;
                }

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndVertical();

                if (string.IsNullOrEmpty(_inputText))
                {
                    EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(false));
                    GUILayout.FlexibleSpace();

                    GUILayout.Label(GuiContentCache.Instance.Error, GUILayout.ExpandWidth(false));

                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndVertical();
                }

                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                if (_contents.Length == 0)
                {
                    GUILayout.Label(GuiContentCache.Instance.NoEventsFound, StyleCache.Instance.CenteredLabel, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                }
                else
                {
                    GUILayout.Space(1);

                    _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition, GUILayout.ExpandHeight(true));

                    _newIndex = GUILayout.SelectionGrid(_selectedIndex, _contents, 1,
                                                        StyleCache.Instance.GridButton,
                                                        GUILayout.ExpandWidth(true));

                    if (_newIndex != _selectedIndex)
                    {
                        _selectedIndex = _newIndex;
                        EventAttribute attr = _actualEventDict[_actualEventList[_selectedIndex]];
                        if (null != attr)
                        {
                            AddEventHandlerDialog.Instance.Data.EventAttribute = _actualEventDict[attr.Name];
                            AddEventHandlerDialog.Instance.Data.EventName      = null;
                        }

                        GotoSignal.Emit(1);
                    }

                    EditorGUILayout.EndScrollView();

                    GUILayout.Space(2);
                }
            }

            EditorGUILayout.EndVertical();  // panel chrome

            GUILayout.Space(1);
        }