Example #1
0
 public static bool Highlight(string windowTitle, string text, HighlightSearchMode mode)
 {
     Stop();
     active = true;
     if (!SetWindow(windowTitle))
     {
         Debug.LogWarning("Window " + windowTitle + " not found.");
         return false;
     }
     activeText = text;
     s_SearchMode = mode;
     s_LastTime = Time.realtimeSinceStartup;
     bool flag = Search();
     if (flag)
     {
         EditorApplication.update = (EditorApplication.CallbackFunction) Delegate.Remove(EditorApplication.update, new EditorApplication.CallbackFunction(Highlighter.Update));
         EditorApplication.update = (EditorApplication.CallbackFunction) Delegate.Combine(EditorApplication.update, new EditorApplication.CallbackFunction(Highlighter.Update));
     }
     else
     {
         Debug.LogWarning("Item " + text + " not found in window " + windowTitle + ".");
         Stop();
     }
     InternalEditorUtility.RepaintAllViews();
     return flag;
 }
Example #2
0
        public static bool Highlight(string windowTitle, string text, HighlightSearchMode mode)
        {
            Stop();
            active = true;
            if (!SetWindow(windowTitle))
            {
                Debug.LogWarning("Window " + windowTitle + " not found.");
                return(false);
            }
            activeText   = text;
            s_SearchMode = mode;
            s_LastTime   = Time.realtimeSinceStartup;
            bool flag = Search();

            if (flag)
            {
                EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.update, new EditorApplication.CallbackFunction(Highlighter.Update));
                EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.update, new EditorApplication.CallbackFunction(Highlighter.Update));
            }
            else
            {
                Debug.LogWarning("Item " + text + " not found in window " + windowTitle + ".");
                Stop();
            }
            InternalEditorUtility.RepaintAllViews();
            return(flag);
        }
Example #3
0
        public static bool Highlight(string windowTitle, string text, HighlightSearchMode mode)
        {
            bool flag = false;

            if (Highlighter.s_RecursionLock || Highlighter.searching)
            {
                Debug.LogWarning("Highlighter recursion detected.  You are calling Highlighter.Highlight() with too much abandon.  Avoid highlighting during layout and repaint events.");
            }
            else if (Event.current != null && Event.current.type == EventType.Layout)
            {
                Debug.LogWarning("You are calling Highlighter.Highlight() inorrectly.  Avoid highlighting during layout and repaint events.");
            }
            else
            {
                Highlighter.s_RecursionLock = true;
                Highlighter.Stop();
                if (!Highlighter.SetWindow(windowTitle))
                {
                    Debug.LogWarning("Window " + windowTitle + " not found.");
                }
                else if (mode != HighlightSearchMode.None)
                {
                    Highlighter.active       = true;
                    Highlighter.activeText   = text;
                    Highlighter.s_SearchMode = mode;
                    Highlighter.s_LastTime   = Time.realtimeSinceStartup;
                    flag = Highlighter.Search();
                    if (flag)
                    {
                        Delegate arg_D8_0 = EditorApplication.update;
                        if (Highlighter.< > f__mg$cache0 == null)
                        {
                            Highlighter.< > f__mg$cache0 = new EditorApplication.CallbackFunction(Highlighter.Update);
                        }
                        EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(arg_D8_0, Highlighter.< > f__mg$cache0);
                        Delegate arg_109_0 = EditorApplication.update;
                        if (Highlighter.< > f__mg$cache1 == null)
                        {
                            Highlighter.< > f__mg$cache1 = new EditorApplication.CallbackFunction(Highlighter.Update);
                        }
                        EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Combine(arg_109_0, Highlighter.< > f__mg$cache1);
                    }
                    else
                    {
                        Debug.LogWarning(string.Concat(new string[]
                        {
                            "Item ",
                            text,
                            " not found in window ",
                            windowTitle,
                            "."
                        }));
                        Highlighter.Stop();
                    }
                    InternalEditorUtility.RepaintAllViews();
                }
                Highlighter.s_RecursionLock = false;
            }
            return(flag);
        }
Example #4
0
        /// <summary>
        ///   <para>Highlights an element in the editor.</para>
        /// </summary>
        /// <param name="windowTitle">The title of the window the element is inside.</param>
        /// <param name="text">The text to identify the element with.</param>
        /// <param name="mode">Optional mode to specify how to search for the element.</param>
        /// <returns>
        ///   <para>true if the requested element was found; otherwise false.</para>
        /// </returns>
        public static bool Highlight(string windowTitle, string text, HighlightSearchMode mode)
        {
            Highlighter.Stop();
            Highlighter.active = true;
            if (!Highlighter.SetWindow(windowTitle))
            {
                Debug.LogWarning((object)("Window " + windowTitle + " not found."));
                return(false);
            }
            Highlighter.activeText   = text;
            Highlighter.s_SearchMode = mode;
            Highlighter.s_LastTime   = Time.realtimeSinceStartup;
            bool flag = Highlighter.Search();

            if (flag)
            {
                EditorApplication.update -= new EditorApplication.CallbackFunction(Highlighter.Update);
                EditorApplication.update += new EditorApplication.CallbackFunction(Highlighter.Update);
            }
            else
            {
                Debug.LogWarning((object)("Item " + text + " not found in window " + windowTitle + "."));
                Highlighter.Stop();
            }
            InternalEditorUtility.RepaintAllViews();
            return(flag);
        }
Example #5
0
        public static bool Highlight(string windowTitle, string text, HighlightSearchMode mode)
        {
            bool success = false;

            if (s_RecursionLock || searching)
            {
                Debug.LogWarning("Highlighter recursion detected.  You are calling Highlighter.Highlight() with too much abandon.  Avoid highlighting during layout and repaint events.");
            }
            else if (Event.current != null && Event.current.type == EventType.Layout)
            {
                Debug.LogWarning("You are calling Highlighter.Highlight() inorrectly.  Avoid highlighting during layout and repaint events.");
            }
            else
            {
                s_RecursionLock = true;
                Stop();

                if (!SetWindow(windowTitle))
                {
                    Debug.LogWarning("Window " + windowTitle + " not found.");
                }
                else if (mode != HighlightSearchMode.None)
                {
                    active       = true;
                    activeText   = text;
                    s_SearchMode = mode;
                    s_LastTime   = Time.realtimeSinceStartup;

                    success = Search();
                    if (success)
                    {
                        // Remove first to make sure it's not added more than once.
                        // Removing is ignored if not already assigned, so causes no harm.
                        EditorApplication.update -= Update;
                        EditorApplication.update += Update;

                        if (s_View.windowBackend is IEditorWindowBackend ewb)
                        {
                            ewb.overlayGUIHandler -= ControlHighlightGUI;
                            ewb.overlayGUIHandler += ControlHighlightGUI;
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Item " + text + " not found in window " + windowTitle + ".");
                        Stop();
                    }

                    // Repaint all views regardless of success of search.
                    // Calling Highlight may have stopped a previous highlight in any case.
                    InternalEditorUtility.RepaintAllViews();
                }
                s_RecursionLock = false;
            }

            return(success);
        }
Example #6
0
 private static bool Search()
 {
     searchMode = s_SearchMode;
     s_View.RepaintImmediately();
     if (searchMode == HighlightSearchMode.None)
     {
         return(true); // Success - control was found
     }
     s_SearchMode = HighlightSearchMode.None;
     Stop();
     return(false);
 }
Example #7
0
        public static bool Highlight(string windowTitle, string text, HighlightSearchMode mode)
        {
            Highlighter.Stop();
            Highlighter.active = true;
            bool result;

            if (!Highlighter.SetWindow(windowTitle))
            {
                Debug.LogWarning("Window " + windowTitle + " not found.");
                result = false;
            }
            else
            {
                Highlighter.activeText   = text;
                Highlighter.s_SearchMode = mode;
                Highlighter.s_LastTime   = Time.realtimeSinceStartup;
                bool flag = Highlighter.Search();
                if (flag)
                {
                    Delegate arg_79_0 = EditorApplication.update;
                    if (Highlighter.< > f__mg$cache0 == null)
                    {
                        Highlighter.< > f__mg$cache0 = new EditorApplication.CallbackFunction(Highlighter.Update);
                    }
                    EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(arg_79_0, Highlighter.< > f__mg$cache0);
                    Delegate arg_AA_0 = EditorApplication.update;
                    if (Highlighter.< > f__mg$cache1 == null)
                    {
                        Highlighter.< > f__mg$cache1 = new EditorApplication.CallbackFunction(Highlighter.Update);
                    }
                    EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Combine(arg_AA_0, Highlighter.< > f__mg$cache1);
                }
                else
                {
                    Debug.LogWarning(string.Concat(new string[]
                    {
                        "Item ",
                        text,
                        " not found in window ",
                        windowTitle,
                        "."
                    }));
                    Highlighter.Stop();
                }
                InternalEditorUtility.RepaintAllViews();
                result = flag;
            }
            return(result);
        }
Example #8
0
        private static bool Search()
        {
            Highlighter.searchMode = Highlighter.s_SearchMode;
            Highlighter.s_View.RepaintImmediately();
            bool result;

            if (Highlighter.searchMode == HighlightSearchMode.None)
            {
                result = true;
            }
            else
            {
                Highlighter.s_SearchMode = HighlightSearchMode.None;
                Highlighter.Stop();
                result = false;
            }
            return(result);
        }
 /// <summary>
 ///   <para>Highlights an element in the editor.</para>
 /// </summary>
 /// <param name="windowTitle">The title of the window the element is inside.</param>
 /// <param name="text">The text to identify the element with.</param>
 /// <param name="mode">Optional mode to specify how to search for the element.</param>
 /// <returns>
 ///   <para>true if the requested element was found; otherwise false.</para>
 /// </returns>
 public static bool Highlight(string windowTitle, string text, HighlightSearchMode mode)
 {
   Highlighter.Stop();
   Highlighter.active = true;
   if (!Highlighter.SetWindow(windowTitle))
   {
     Debug.LogWarning((object) ("Window " + windowTitle + " not found."));
     return false;
   }
   Highlighter.activeText = text;
   Highlighter.s_SearchMode = mode;
   Highlighter.s_LastTime = Time.realtimeSinceStartup;
   bool flag = Highlighter.Search();
   if (flag)
   {
     EditorApplication.update -= new EditorApplication.CallbackFunction(Highlighter.Update);
     EditorApplication.update += new EditorApplication.CallbackFunction(Highlighter.Update);
   }
   else
   {
     Debug.LogWarning((object) ("Item " + text + " not found in window " + windowTitle + "."));
     Highlighter.Stop();
   }
   InternalEditorUtility.RepaintAllViews();
   return flag;
 }