Esempio n. 1
0
        static void DisplayObjects()
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition, true, true);

            GUI.backgroundColor = Color.black;

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            GUILayout.Label("Texts containing \"" + _wordToSearch + "\"", EditorStyles.boldLabel);

            for (int i = 0; i < _textsWithWord.Count; i++)
            {
                if (_textsWithWord[i] != null)
                {
                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUILayout.ObjectField(_textsWithWord[i].textObject, typeof(GameObject), true);
                    EditorGUI.EndDisabledGroup();
                    EditorGUILayout.BeginHorizontal();

                    GUILayout.Space(50);

                    var areaStyle = new GUIStyle(GUI.skin.label);
                    areaStyle.wordWrap = true;
                    areaStyle.fontSize = 14;
                    areaStyle.margin   = new RectOffset(2, 0, 10, 10);
                    areaStyle.CalcSize(new GUIContent(_textsWithWord[i].text));
                    areaStyle.richText = true;

                    if (_tempIgnoreCase)
                    {
                        if (!String.IsNullOrEmpty(_wordToSearch))
                        {
                            string newText = Regex.Replace(_textsWithWord[i].text, _wordToSearch, "<color=yellow>" + _wordToSearch + "</color>", RegexOptions.IgnoreCase);
                            EditorGUILayout.TextArea(newText, areaStyle);
                        }
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(_wordToSearch))
                        {
                            EditorGUILayout.TextArea(_textsWithWord[i].text.Replace(_wordToSearch, "<color=yellow>" + _wordToSearch + "</color>"), areaStyle);
                        }
                    }

                    GUI.color = Color.white;

                    EditorGUILayout.EndHorizontal();

                    if (i + 1 < _textsWithWord.Count)
                    {
                        GUILayoutExtension.DrawHorizontalLine();
                    }
                }
            }

            EditorGUILayout.EndVertical();
        }
Esempio n. 2
0
        void OnGUI()
        {
            //Some styles
            guiStyle_RedBold16.fontSize         = 16;
            guiStyle_RedBold16.fontStyle        = FontStyle.Bold;
            guiStyle_RedBold16.normal.textColor = Color.white;
            guiStyle_RedBold16.alignment        = TextAnchor.MiddleCenter;

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Find words in scene", guiStyle_RedBold16);
            EditorGUILayout.Space();

            _tempWord = _wordToSearch;

            GUI.backgroundColor = Color.cyan;
            _wordToSearch       = EditorGUILayout.TextField("Word(s) to search : ", _wordToSearch);
            GUI.backgroundColor = Color.white;

            _tempIgnoreCase = _ignoreCase;
            _ignoreCase     = EditorGUILayout.Toggle("Ignore uppercase : ", _ignoreCase);

            _comparison = (_ignoreCase == true) ? _comparison = StringComparison.OrdinalIgnoreCase : _comparison = StringComparison.Ordinal;

            //Automatic Refresh (if the word change or the case change)
            if ((!_wordToSearch.Equals(_tempWord)) || (!_ignoreCase.Equals(_tempIgnoreCase)))
            {
                _searching = true;
            }

            //Manual Refresh
            GUI.backgroundColor = Color.cyan;
            GUILayout.BeginHorizontal();
            GUI.skin.button.fontStyle = FontStyle.Bold;
            GUI.skin.button.fontSize  = 11;
            if (GUILayout.Button("REFRESH", new GUILayoutOption[] { GUILayout.Width(150), GUILayout.Height(25) }))
            {
                _searching = true;
                SearchingTexts();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUI.backgroundColor = Color.white;

            //Refresh
            if (_searching)
            {
                _textsWithWord = LookingForWord(_texts, _wordToSearch);
                _searching     = false;
            }

            GUILayoutExtension.DrawHorizontalLine("Research");

            DisplayObjects();

            GUILayout.EndScrollView();
        }