private string DoTextField(string text, GUIStyle textFieldStyle)
        {
            if (m_TextFieldControlID == 0)
            {
                Debug.LogError(
                    "RenameOverlay: Ensure to call OnEvent() as early as possible in the OnGUI of the current EditorWindow!");
            }

            if (s_DefaultTextFieldStyle == null)
            {
                s_DefaultTextFieldStyle = "PR TextField";
            }

            if (isRenamingFilename)
            {
                EatInvalidChars();
            }

            GUI.changed = false;
            if (GUIUtility.keyboardControl != m_TextFieldControlID)
            {
                GUIUtility.keyboardControl = m_TextFieldControlID;
            }

            bool changed;

            return(EditorGUIWrap.DoTextField(EditorGUIWrap.RecycledEditor, m_TextFieldControlID,
                                             IndentedRect(m_EditFieldRect), text, textFieldStyle ?? s_DefaultTextFieldStyle, null, out changed,
                                             false, false, false));
        }
示例#2
0
        private void SearchField()
        {
            float maxWidth = (EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth + 5.0f) * 1.5f;

            GUILayoutOption[] guiLayoutOptionArray = new GUILayoutOption[2];
            guiLayoutOptionArray[0] = GUILayout.MinWidth(65f);
            guiLayoutOptionArray[1] = GUILayout.MaxWidth(300f);
            Rect rect      = GUILayoutUtility.GetRect(0, maxWidth, 16, 16, EditorStylesWrap.toolbarSearchField, guiLayoutOptionArray);
            int  controlId = GUIUtility.GetControlID(m_HashForSearchField, FocusType.Passive, rect);

            if (m_FocusSearchField)
            {
                GUIUtility.keyboardControl        = controlId;
                EditorGUIUtility.editingTextField = true;
                if (Event.current.type == EventType.Repaint)
                {
                    m_FocusSearchField = false;
                }
            }

            Event current = Event.current;

            if (current.type == EventType.KeyDown &&
                (current.keyCode == KeyCode.DownArrow || current.keyCode == KeyCode.UpArrow) &&
                GUIUtility.keyboardControl == controlId)
            {
                if (UpOrDownArrowPressedAction != null)
                {
                    UpOrDownArrowPressedAction();
                }
                current.Use();
            }

            string str = EditorGUIWrap.ToolbarSearchField(controlId, rect, m_SearchFieldText, false);

            if (str == m_SearchFieldText && !m_FocusSearchField)
            {
                return;
            }

            SearchText = str;
            Repaint();
        }
示例#3
0
        void OnGUI()
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            GUI.Label(new Rect(0.0f, 0.0f, position.width, position.height), GUIContent.none, s_Styles.background);
            if (m_DirtyList)
            {
                CreateComponentTree();
            }
            HandleKeyboard();
            GUILayout.Space(7f);


            EditorGUI.FocusTextInControl(s_ItemSearchKey);
            Rect rect = GUILayoutUtility.GetRect(10f, 20f);

            rect.x     += 8f;
            rect.width -= 16f;
            GUI.SetNextControlName(s_ItemSearchKey);

            string str = EditorGUIWrap.SearchField(rect, m_DelayedSearch ?? m_Search);

            if (str != m_Search || m_DelayedSearch != null)
            {
                if (!isAnimating)
                {
                    m_Search = m_DelayedSearch ?? str;
                    EditorPrefs.SetString(s_ItemSearchKey, m_Search);
                    RebuildSearch();
                    m_DelayedSearch = null;
                }
                else
                {
                    m_DelayedSearch = str;
                }
            }

            ListGUI(activeTree, m_Anim, GetElementRelative(0), GetElementRelative(-1));
            if (m_Anim < 1.0)
            {
                ListGUI(activeTree, m_Anim + 1f, GetElementRelative(-1), GetElementRelative(-2));
            }

            if (!isAnimating || Event.current.type != EventType.Repaint)
            {
                return;
            }

            long  ticks = DateTime.Now.Ticks;
            float num   = (ticks - m_LastTime) / 1E+07f;

            m_LastTime = ticks;
            m_Anim     = Mathf.MoveTowards(m_Anim, m_AnimTarget, num * 4f);
            if (m_AnimTarget == 0 && m_Anim == 0.0)
            {
                m_Anim       = 1f;
                m_AnimTarget = 1;
                m_Stack.RemoveAt(m_Stack.Count - 1);
            }
            Repaint();
        }