示例#1
0
        public override void Draw(SearchOptions options)
        {
            float lw = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = SRWindow.compactLabelWidth;

            GUILayout.BeginHorizontal();
            UnityEngine.Object newValue = EditorGUILayout.ObjectField("Value:", searchValue.obj, typeof(UnityEngine.Object), true);
            EditorGUIUtility.labelWidth = lw; // i love stateful gui! :(

            if (newValue != searchValue.obj)
            {
                UnityEngine.Object scriptObject = ObjectUtil.getScriptObjectFromObject(newValue);
                if (scriptObject == null && newValue != null)
                {
                    //looks like we couldn't get an object! Is it a directory?
                    if (ObjectUtil.IsDirectory(newValue))
                    {
                        setFolder(newValue);
                    }
                    else
                    {
                        Debug.Log("[Project Search & Replace] " + newValue + " isn't a Folder, Component, MonoBehaviour, ScriptableObject or MonoScript.");
                    }
                }
                else
                {
                    SetObject(scriptObject);
                }
                SRWindow.Instance.PersistCurrentSearch();
            }
            if (type != null)
            {
                GUILayout.Label("(" + type.Name + ")");
            }
            GUILayout.EndHorizontal();
            if (searchValue.isDirectory)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(SRWindow.compactLabelWidth + 4);
                bool newShowUnused = EditorGUILayout.ToggleLeft("Show Unused Scripts", showUnusedScripts);
                GUILayout.EndHorizontal();

                if (newShowUnused != showUnusedScripts)
                {
                    showUnusedScripts = newShowUnused;
                    SRWindow.Instance.PersistCurrentSearch();
                }
            }
            if (showMoreOptions)
            {
                if (SRWindow.Instance.Compact())
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(SRWindow.compactLabelWidth);
                }
                if (!searchValue.isDirectory)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(SRWindow.compactLabelWidth + 4);
                    bool newMatchChildClasses = EditorGUILayout.ToggleLeft("Match Child Classes?", matchChildClasses);
                    GUILayout.EndHorizontal();
                    if (newMatchChildClasses != matchChildClasses)
                    {
                        matchChildClasses = newMatchChildClasses;
                        SRWindow.Instance.PersistCurrentSearch();
                    }
                }

                GUILayout.BeginHorizontal();
                GUILayout.Space(SRWindow.compactLabelWidth + 4);
                bool newMatchAssetMissingScript = EditorGUILayout.ToggleLeft("Match assets where script is missing.", matchAssetMissingScript);
                GUILayout.EndHorizontal();
                if (newMatchAssetMissingScript != matchAssetMissingScript)
                {
                    matchAssetMissingScript = newMatchAssetMissingScript;
                    SRWindow.Instance.PersistCurrentSearch();
                }

                if (SRWindow.Instance.Compact())
                {
                    GUILayout.EndHorizontal();
                }
            }

            drawReplaceItem(options);
        }
示例#2
0
        public override void Draw(SearchOptions options)
        {
            GUILayout.BeginHorizontal();
            SRWindow.Instance.CVS();

            drawControlStart();
            string newValue = EditorGUILayout.TextField(displayValue, GUILayout.MaxWidth(SRWindow.Instance.position.width - SRWindow.boxPad));

            GUILayout.EndHorizontal();
            if (newValue != displayValue)
            {
                displayValue = newValue;
                searchValue  = StringUtil.Unescape(newValue);
                SRWindow.Instance.PersistCurrentSearch();
            }

            if (showMoreOptions)
            {
                if (SRWindow.Instance.Compact())
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Space(SRWindow.compactLabelWidthEP);
                }
                EditorGUILayout.BeginHorizontal();
                SRWindow.Instance.CVS();

                bool newIgnoreCase = EditorGUILayout.ToggleLeft(caseSensitiveGUI, ignoreCase, GUILayout.Width(95));
                if (newIgnoreCase != ignoreCase)
                {
                    ignoreCase = newIgnoreCase;
                    SRWindow.Instance.PersistCurrentSearch();
                }
                GUI.enabled = !regex && !anyValueEquals();
                bool newContains = EditorGUILayout.ToggleLeft(exactMatchGUI, contains, GUILayout.Width(75));
                if (newContains != contains)
                {
                    contains = newContains;
                    SRWindow.Instance.PersistCurrentSearch();
                }
                GUI.enabled = !anyValueEquals();
                bool newRegex = EditorGUILayout.ToggleLeft(regexGUI, regex, GUILayout.Width(60));
                if (newRegex != regex)
                {
                    regex = newRegex;
                    SRWindow.Instance.PersistCurrentSearch();
                }
                SRWindow.Instance.CVE();
                EditorGUILayout.EndHorizontal();
                if (SRWindow.Instance.Compact())
                {
                    EditorGUILayout.EndHorizontal();
                }
            }
            GUI.enabled = true;


            if (regex)
            {
                RegexOptions regexOptions = RegexOptions.Singleline | RegexOptions.Compiled;
                if (ignoreCase)
                {
                    regexOptions |= RegexOptions.IgnoreCase;
                }
                try{
                    expr       = new Regex(searchValue, regexOptions);
                    regexValid = true;
                }catch
                {
                    expr       = null;
                    regexValid = false;
                }
            }
            SRWindow.Instance.CVE();
            GUILayout.EndHorizontal();
            drawReplaceItem(options);
        }