Exemple #1
0
    protected void Add(string text, int size, bool bold, string color, GuiRendererControl control)
    {
        RichTextFormatter textFormatter = RichTextFormatter.For(text);

        if (color.Length > 0)
        {
            textFormatter.SetColor(color);
        }
        if (bold)
        {
            textFormatter.SetBold();
        }
        textFormatter.SetSize(Pixels.GetDensityIndependentPixels(size));
        text = textFormatter.Format();

        GuiPosition            position            = lastGuiElement == null ? firstPosition : defaultPosition;
        GuiTextRendererBuilder textRendererBuilder = new GuiTextRendererBuilder().WithRichText(text).InPosition(position, lastGuiElement);

        if (control != null)
        {
            textRendererBuilder.WithControl(control);
        }

        lastGuiElement = textRendererBuilder.Get();
        manager.AddElement(new GuiStaticElement(lastGuiElement));
    }
    private RichTextFormatter addPointsStatusFormat(RichTextFormatter formatter)
    {
        if (data.Ended) {
            formatter.SetBold();
        }

        return formatter;
    }
    private RichTextFormatter addPointsStatusFormat(RichTextFormatter formatter)
    {
        if (data.Ended)
        {
            formatter.SetBold();
        }

        return(formatter);
    }
    public override string GetText()
    {
        RichTextFormatter formatter = RichTextFormatter.For(data.PlayerName + ": " + data.Points + " puntos")
                                      .SetColor(TEXT_COLOR)
                                      .SetSize(TEXT_SIZE);

        addPointsStatusFormat(formatter);

        return(formatter.Format());
    }
Exemple #5
0
    public static GuiManagerElement GetEndElement(GamePoints maxPoints, GuiRendererControl backToMenuControl, GuiRendererControl showRankingControl)
    {
        GuiTextRenderer mapEndedRenderer = new GuiTextRendererBuilder()
                                           .WithRichText(RichTextFormatter.For("Mapa finalizado")
                                                         .SetBold()
                                                         .SetColor("lime")
                                                         .SetSize(Pixels.GetDensityIndependentPixels(40))
                                                         .Format())
                                           .InPosition(GuiPosition.UP_CENTER)
                                           .Get();

        GuiTextRenderer freeSpaceBetweenButtonsRenderer = new GuiTextRendererBuilder()
                                                          .WithRichText(RichTextFormatter.For("\xa0")
                                                                        .SetSize(Pixels.GetDensityIndependentPixels(25))
                                                                        .Format())
                                                          .InPosition(GuiPosition.DOWN_CENTER)
                                                          .Get();

        GuiTextRenderer showRankingRenderer = new GuiTextRendererBuilder()
                                              .WithRichText(RichTextFormatter.For("Ver clasificaci\xf3n")
                                                            .SetBold()
                                                            .SetColor("red")
                                                            .SetSize(Pixels.GetDensityIndependentPixels(25))
                                                            .Format())
                                              .InPosition(GuiPosition.BEFORE, freeSpaceBetweenButtonsRenderer)
                                              .WithControl(showRankingControl)
                                              .Get();

        GuiTextRenderer backToMenuRenderer = new GuiTextRendererBuilder()
                                             .WithRichText(RichTextFormatter.For("Volver al men\xfa")
                                                           .SetBold()
                                                           .SetColor("cyan")
                                                           .SetSize(Pixels.GetDensityIndependentPixels(25))
                                                           .Format())
                                             .InPosition(GuiPosition.NEXT, freeSpaceBetweenButtonsRenderer)
                                             .WithControl(backToMenuControl)
                                             .Get();

        GuiTextRenderer maxPointsRenderer = new GuiTextRendererBuilder()
                                            .WithRichText(RichTextFormatter.For("Tu r\x00e9cord: " + maxPoints.Points + " puntos")
                                                          .SetBold()
                                                          .SetColor("cyan")
                                                          .SetSize(Pixels.GetDensityIndependentPixels(20))
                                                          .Format())
                                            .InPosition(GuiPosition.CENTER_HALF_DOWN)
                                            .Get();

        return(new GuiElementGroup()
               .AddElement(new GuiStaticElement(mapEndedRenderer))
               .AddElement(new GuiStaticElement(freeSpaceBetweenButtonsRenderer))
               .AddElement(new GuiStaticElement(showRankingRenderer))
               .AddElement(new GuiStaticElement(backToMenuRenderer))
               .AddElement(new GuiStaticElement(maxPointsRenderer)));
    }
Exemple #6
0
 private static GuiTextRenderer buildFullRenderer(string text, string textColor, int textSize, GuiPosition position, GuiRendererControl control)
 {
     return(new GuiTextRendererBuilder()
            .WithRichText(RichTextFormatter.For(text)
                          .SetBold()
                          .SetColor(textColor)
                          .SetSize(Pixels.GetDensityIndependentPixels(textSize))
                          .Format())
            .InPosition(position)
            .WithControl(control)
            .Get());
 }
        /// <summary>
        /// Creates one of the Default formatters.
        /// </summary>
        private void CreateFormatter()
        {
            switch (Format)
            {
            case TextToolbarFormats.Format.MarkDown:
                Formatter = new MarkDownFormatter(this);
                break;

            case TextToolbarFormats.Format.RichText:
                Formatter = new RichTextFormatter(this);
                break;
            }
        }
        public SceneProvider(string providerId, string filterId, string displayName)
            : base(providerId, displayName)
        {
            priority           = 50;
            this.filterId      = filterId;
            this.showDetails   = true;
            showDetailsOptions = ShowDetailsOptions.Inspector | ShowDetailsOptions.Actions;

            isEnabledForContextualSearch = () =>
                                           Utils.IsFocusedWindowTypeName("SceneView") ||
                                           Utils.IsFocusedWindowTypeName("SceneHierarchyWindow");

            EditorApplication.hierarchyChanged += () => m_HierarchyChanged = true;

            onEnable = () =>
            {
                if (m_HierarchyChanged)
                {
                    m_GameObjects      = fetchGameObjects();
                    m_SceneQueryEngine = new SceneQueryEngine(m_GameObjects);
                    m_HierarchyChanged = false;
                }
            };

            onDisable = () =>
            {
                // Only track changes that occurs when Quick Search is not active.
                m_HierarchyChanged = false;
            };

            toObject = (item, type) => ObjectFromItem(item);

            fetchItems = (context, items, provider) => SearchItems(context, provider);

            fetchLabel = (item, context) =>
            {
                if (item.label != null)
                {
                    return(item.label);
                }

                var go = ObjectFromItem(item);
                if (!go)
                {
                    return(item.id);
                }

                if (context.searchView == null || context.searchView.displayMode == DisplayMode.List)
                {
                    var transformPath = SearchUtils.GetTransformPath(go.transform);
                    var components    = go.GetComponents <Component>();
                    if (components.Length > 2 && components[1] && components[components.Length - 1])
                    {
                        item.label = $"{transformPath} ({components[1].GetType().Name}..{components[components.Length - 1].GetType().Name})";
                    }
                    else if (components.Length > 1 && components[1])
                    {
                        item.label = $"{transformPath} ({components[1].GetType().Name})";
                    }
                    else
                    {
                        item.label = $"{transformPath} ({item.id})";
                    }

                    long       score   = 1;
                    List <int> matches = new List <int>();
                    var        sq      = Utils.CleanString(context.searchQuery);
                    if (FuzzySearch.FuzzyMatch(sq, Utils.CleanString(item.label), ref score, matches))
                    {
                        item.label = RichTextFormatter.FormatSuggestionTitle(item.label, matches);
                    }
                }
                else
                {
                    item.label = go.name;
                }

                return(item.label);
            };

            fetchDescription = (item, context) =>
            {
                var go = ObjectFromItem(item);
                return(item.description = SearchUtils.GetHierarchyPath(go));
            };

            fetchThumbnail = (item, context) =>
            {
                var obj = ObjectFromItem(item);
                if (obj == null)
                {
                    return(null);
                }

                return(item.thumbnail = Utils.GetThumbnailForGameObject(obj));
            };

            fetchPreview = (item, context, size, options) =>
            {
                var obj = ObjectFromItem(item);
                if (obj == null)
                {
                    return(item.thumbnail);
                }
                return(Utils.GetSceneObjectPreview(obj, size, options, item.thumbnail));
            };

            startDrag = (item, context) =>
            {
                Utils.StartDrag(context.selection.Select(i => ObjectFromItem(i)).ToArray(), item.GetLabel(context, true));
            };

            trackSelection = (item, context) => PingItem(item);

            fetchGameObjects       = SceneQueryEngine.FetchGameObjects;
            buildKeywordComponents = SceneQueryEngine.BuildKeywordComponents;
        }
Exemple #9
0
        public SceneProvider(string providerId, string filterId, string displayName)
            : base(providerId, displayName)
        {
            priority      = 50;
            this.filterId = filterId;

            subCategories = new List <NameId>
            {
                new NameId("fuzzy", "fuzzy"),
            };

            isEnabledForContextualSearch = () =>
                                           QuickSearchTool.IsFocusedWindowTypeName("SceneView") ||
                                           QuickSearchTool.IsFocusedWindowTypeName("SceneHierarchyWindow");

            EditorApplication.hierarchyChanged += () => m_HierarchyChanged = true;

            onEnable = () =>
            {
                if (m_HierarchyChanged)
                {
                    componentsById.Clear();
                    indexer = null;
                    gods    = null;
                    m_GodBuilderEnumerator = null;
                    m_HierarchyChanged     = false;
                }
            };

            onDisable = () => {};

            fetchItems = (context, items, provider) => FetchItems(context, provider);

            fetchLabel = (item, context) =>
            {
                if (item.label != null)
                {
                    return(item.label);
                }

                var go = ObjectFromItem(item);
                if (!go)
                {
                    return(item.id);
                }

                var transformPath = GetTransformPath(go.transform);
                var components    = go.GetComponents <Component>();
                if (components.Length > 2 && components[1] && components[components.Length - 1])
                {
                    item.label = $"{transformPath} ({components[1].GetType().Name}..{components[components.Length-1].GetType().Name})";
                }
                else if (components.Length > 1 && components[1])
                {
                    item.label = $"{transformPath} ({components[1].GetType().Name})";
                }
                else
                {
                    item.label = $"{transformPath} ({item.id})";
                }

                long       score   = 1;
                List <int> matches = new List <int>();
                var        sq      = CleanString(context.searchQuery);
                if (FuzzySearch.FuzzyMatch(sq, CleanString(item.label), ref score, matches))
                {
                    item.label = RichTextFormatter.FormatSuggestionTitle(item.label, matches);
                }

                return(item.label);
            };

            fetchDescription = (item, context) =>
            {
                #if QUICKSEARCH_DEBUG
                item.description = gods[(int)item.data].name + " * " + item.score;
                #else
                var go = ObjectFromItem(item);
                item.description = GetHierarchyPath(go);
                #endif
                return(item.description);
            };

            fetchThumbnail = (item, context) =>
            {
                var obj = ObjectFromItem(item);
                if (obj == null)
                {
                    return(null);
                }

                item.thumbnail = PrefabUtility.GetIconForGameObject(obj);
                if (item.thumbnail)
                {
                    return(item.thumbnail);
                }
                return(EditorGUIUtility.ObjectContent(obj, obj.GetType()).image as Texture2D);
            };

            fetchPreview = (item, context, size, options) =>
            {
                var obj = ObjectFromItem(item);
                if (obj == null)
                {
                    return(item.thumbnail);
                }

                var assetPath = GetHierarchyAssetPath(obj, true);
                if (String.IsNullOrEmpty(assetPath))
                {
                    return(item.thumbnail);
                }
                return(AssetPreview.GetAssetPreview(obj) ?? Utils.GetAssetPreviewFromPath(assetPath));
            };

            startDrag = (item, context) =>
            {
                var obj = ObjectFromItem(item);
                if (obj != null)
                {
                    DragAndDrop.PrepareStartDrag();
                    DragAndDrop.objectReferences = new[] { obj };
                    DragAndDrop.StartDrag("Drag scene object");
                }
            };

            fetchGameObjects       = FetchGameObjects;
            buildKeywordComponents = BuildKeywordComponents;

            trackSelection = (item, context) => PingItem(item);
        }
Exemple #10
0
        public SceneProvider(string providerId, string filterId, string displayName)
            : base(providerId, displayName)
        {
            priority = 50;
            this.filterId = filterId;
            this.showDetails = true;

            subCategories = new List<NameEntry>
            {
                new NameEntry("fuzzy", "fuzzy")
            };

            isEnabledForContextualSearch = () =>
                QuickSearch.IsFocusedWindowTypeName("SceneView") ||
                QuickSearch.IsFocusedWindowTypeName("SceneHierarchyWindow");

            EditorApplication.hierarchyChanged += () => m_HierarchyChanged = true;

            onEnable = () =>
            {
                if (m_HierarchyChanged)
                {
                    m_BuildIndexEnumerator = null;
                    m_HierarchyChanged = false;
                }
            };

            onDisable = () =>
            {
                // Only track changes that occurs when Quick Search is not active.
                m_HierarchyChanged = false;
            };

            fetchItems = (context, items, provider) => SearchItems(context, provider);

            fetchLabel = (item, context) =>
            {
                if (item.label != null)
                    return item.label;

                var go = ObjectFromItem(item);
                if (!go)
                    return item.id;

                var transformPath = GetTransformPath(go.transform);
                var components = go.GetComponents<Component>();
                if (components.Length > 2 && components[1] && components[components.Length-1])
                    item.label = $"{transformPath} ({components[1].GetType().Name}..{components[components.Length-1].GetType().Name})";
                else if (components.Length > 1 && components[1])
                    item.label = $"{transformPath} ({components[1].GetType().Name})";
                else
                    item.label = $"{transformPath} ({item.id})";

                long score = 1;
                List<int> matches = new List<int>();
                var sq = CleanString(context.searchQuery);
                if (FuzzySearch.FuzzyMatch(sq, CleanString(item.label), ref score, matches))
                    item.label = RichTextFormatter.FormatSuggestionTitle(item.label, matches);

                return item.label;
            };

            fetchDescription = (item, context) =>
            {
                var go = ObjectFromItem(item);
                return (item.description = GetHierarchyPath(go));
            };

            fetchThumbnail = (item, context) =>
            {
                var obj = ObjectFromItem(item);
                if (obj == null)
                    return null;

                return (item.thumbnail = Utils.GetThumbnailForGameObject(obj));
            };

            fetchPreview = (item, context, size, options) =>
            {
                var obj = ObjectFromItem(item);
                if (obj == null)
                    return item.thumbnail;

                var assetPath = GetHierarchyAssetPath(obj, true);
                if (String.IsNullOrEmpty(assetPath))
                    return item.thumbnail;
                return Utils.GetAssetPreviewFromPath(assetPath, size, options) ?? AssetPreview.GetAssetPreview(obj);
            };

            startDrag = (item, context) =>
            {
                var obj = ObjectFromItem(item);
                if (obj != null)
                    Utils.StartDrag(obj, item.label);
            };

            fetchGameObjects = FetchGameObjects;
            buildKeywordComponents = o => null;

            trackSelection = (item, context) => PingItem(item);
        }
Exemple #11
0
        public SceneProvider(string providerId, string filterId, string displayName)
            : base(providerId, displayName)
        {
            priority           = 50;
            this.filterId      = filterId;
            showDetails        = true;
            showDetailsOptions = ShowDetailsOptions.Inspector | ShowDetailsOptions.Actions | ShowDetailsOptions.Preview | ShowDetailsOptions.DefaultGroup;

            isEnabledForContextualSearch = () =>
                                           Utils.IsFocusedWindowTypeName("SceneView") ||
                                           Utils.IsFocusedWindowTypeName("SceneHierarchyWindow");

            SearchMonitor.sceneChanged         += InvalidateScene;
            SearchMonitor.documentsInvalidated += Refresh;

            SearchMonitor.objectChanged += OnObjectChanged;

            supportsSyncViewSearch = true;

            toObject = (item, type) => ObjectFromItem(item, type);
            toKey    = (item) => ToKey(item);

            fetchItems = (context, items, provider) => SearchItems(context, provider);

            fetchLabel = (item, context) =>
            {
                if (item.label != null)
                {
                    return(item.label);
                }

                var go = ObjectFromItem(item);
                if (!go)
                {
                    return(item.id);
                }

                if (context == null || context.searchView == null || context.searchView.displayMode == DisplayMode.List)
                {
                    var transformPath = SearchUtils.GetTransformPath(go.transform);
                    if (item.options.HasAny(SearchItemOptions.Compacted))
                    {
                        item.label = transformPath;
                    }
                    else
                    {
                        var components = go.GetComponents <Component>();
                        if (components.Length > 2 && components[1] && components[components.Length - 1])
                        {
                            item.label = $"{transformPath} ({components[1].GetType().Name}..{components[components.Length - 1].GetType().Name})";
                        }
                        else if (components.Length > 1 && components[1])
                        {
                            item.label = $"{transformPath} ({components[1].GetType().Name})";
                        }
                        else
                        {
                            item.label = $"{transformPath} ({item.id})";
                        }
                    }

                    if (context != null)
                    {
                        long       score   = 1;
                        List <int> matches = new List <int>();
                        var        sq      = Utils.CleanString(context.searchQuery);
                        if (FuzzySearch.FuzzyMatch(sq, Utils.CleanString(item.label), ref score, matches))
                        {
                            item.label = RichTextFormatter.FormatSuggestionTitle(item.label, matches);
                        }
                    }
                }
                else
                {
                    item.label = go.name;
                }

                return(item.label);
            };

            fetchDescription = (item, context) =>
            {
                var go = ObjectFromItem(item);
                return(item.description = SearchUtils.GetHierarchyPath(go));
            };

            fetchThumbnail = (item, context) =>
            {
                var obj = ObjectFromItem(item);
                if (obj == null)
                {
                    return(null);
                }

                return(item.thumbnail = Utils.GetThumbnailForGameObject(obj));
            };

            fetchPreview = (item, context, size, options) =>
            {
                var obj = ObjectFromItem(item);
                if (obj == null)
                {
                    return(item.thumbnail);
                }
                return(Utils.GetSceneObjectPreview(obj, size, options, item.thumbnail));
            };

            startDrag = (item, context) =>
            {
                if (context.selection.Count > 1)
                {
                    Utils.StartDrag(context.selection.Select(i => ObjectFromItem(i)).ToArray(), item.GetLabel(context, true));
                }
                else
                {
                    Utils.StartDrag(new[] { ObjectFromItem(item) }, item.GetLabel(context, true));
                }
            };

            fetchPropositions = (context, options) =>
            {
                if (options.HasAny(SearchPropositionFlags.QueryBuilder))
                {
                    return(FetchQueryBuilderPropositions(context));
                }
                return(m_SceneQueryEngine == null ? new SearchProposition[0] : m_SceneQueryEngine.FindPropositions(context, options));
            };

            trackSelection = (item, context) => PingItem(item);

            fetchColumns = (context, items) => SceneSelectors.Enumerate(items);
        }
Exemple #12
0
        public SceneProvider(string providerId, string filterId, string displayName)
            : base(providerId, displayName)
        {
            priority      = 50;
            this.filterId = filterId;

            isEnabledForContextualSearch = () =>
                                           Utils.IsFocusedWindowTypeName("SceneView") ||
                                           Utils.IsFocusedWindowTypeName("SceneHierarchyWindow");

            EditorApplication.hierarchyChanged += () => m_HierarchyChanged = true;

            onEnable = () =>
            {
                if (m_HierarchyChanged)
                {
                    m_GameObjects      = fetchGameObjects();
                    m_SceneQueryEngine = new SceneQueryEngine(m_GameObjects);
                    m_HierarchyChanged = false;
                }
            };

            onDisable = () =>
            {
                // Only track changes that occurs when Quick Search is not active.
                m_HierarchyChanged = false;
            };

            toObject = (item, type) => ObjectFromItem(item);

            fetchItems = (context, items, provider) => SearchItems(context, provider);

            fetchLabel = (item, context) =>
            {
                if (item.label != null)
                {
                    return(item.label);
                }

                var go = ObjectFromItem(item);
                if (!go)
                {
                    return(item.id);
                }

                if (context.searchView == null || context.searchView.displayMode == DisplayMode.List)
                {
                    var transformPath = SearchUtils.GetTransformPath(go.transform);
                    var components    = go.GetComponents <Component>();
                    if (components.Length > 2 && components[1] && components[components.Length - 1])
                    {
                        item.label = $"{transformPath} ({components[1].GetType().Name}..{components[components.Length - 1].GetType().Name})";
                    }
                    else if (components.Length > 1 && components[1])
                    {
                        item.label = $"{transformPath} ({components[1].GetType().Name})";
                    }
                    else
                    {
                        item.label = $"{transformPath} ({item.id})";
                    }

                    long       score   = 1;
                    List <int> matches = new List <int>();
                    var        sq      = Utils.CleanString(context.searchQuery);
                    if (FuzzySearch.FuzzyMatch(sq, Utils.CleanString(item.label), ref score, matches))
                    {
                        item.label = RichTextFormatter.FormatSuggestionTitle(item.label, matches);
                    }
                }
                else
                {
                    item.label = go.name;
                }

                return(item.label);
            };

            fetchDescription = (item, context) =>
            {
                var go = ObjectFromItem(item);
                return(item.description = SearchUtils.GetHierarchyPath(go));
            };

            fetchThumbnail = (item, context) =>
            {
                var obj = ObjectFromItem(item);
                if (obj == null)
                {
                    return(null);
                }

                return(item.thumbnail = Utils.GetThumbnailForGameObject(obj));
            };

            fetchPreview = (item, context, size, options) =>
            {
                var obj = ObjectFromItem(item);
                if (obj == null)
                {
                    return(item.thumbnail);
                }

                var sr = obj.GetComponent <SpriteRenderer>();
                if (sr && sr.sprite && sr.sprite.texture)
                {
                    return(sr.sprite.texture);
                }

                #if PACKAGE_UGUI
                var uii = obj.GetComponent <UnityEngine.UI.Image>();
                if (uii && uii.mainTexture is Texture2D uiit)
                {
                    return(uiit);
                }
                #endif

                var preview = AssetPreview.GetAssetPreview(obj);
                if (preview)
                {
                    return(preview);
                }

                var assetPath = SearchUtils.GetHierarchyAssetPath(obj, true);
                if (String.IsNullOrEmpty(assetPath))
                {
                    return(item.thumbnail);
                }
                return(Utils.GetAssetPreviewFromPath(assetPath, size, options));
            };

            startDrag = (item, context) =>
            {
                var obj = ObjectFromItem(item);
                if (obj != null)
                {
                    Utils.StartDrag(obj, item.label);
                }
            };

            trackSelection = (item, context) => PingItem(item);

            fetchGameObjects       = SceneQueryEngine.FetchGameObjects;
            buildKeywordComponents = SceneQueryEngine.BuildKeywordComponents;
        }
Exemple #13
0
        public SceneObjectsProvider(string providerId, string displayName = null)
            : base(providerId, displayName)
        {
            priority = 50;
            filterId = "h:";

            subCategories = new List <NameId>
            {
                new NameId("fuzzy", "fuzzy"),
                new NameId("limit", $"limit to {k_LimitMatches} matches")
            };

            isEnabledForContextualSearch = () =>
                                           QuickSearchTool.IsFocusedWindowTypeName("SceneView") ||
                                           QuickSearchTool.IsFocusedWindowTypeName("SceneHierarchyWindow");

            EditorApplication.hierarchyChanged += () => componentsById.Clear();

            onEnable = () =>
            {
                //using (new DebugTimer("Building Scene Object Description"))
                {
                    var objects     = new GameObject[0];
                    var prefabStage = PrefabStageUtility.GetCurrentPrefabStage();
                    if (prefabStage != null)
                    {
                        objects = SceneModeUtility.GetObjects(new[] { prefabStage.prefabContentsRoot }, true);
                    }
                    else
                    {
                        var goRoots = new List <UnityEngine.Object>();
                        for (int i = 0; i < UnityEngine.SceneManagement.SceneManager.sceneCount; ++i)
                        {
                            goRoots.AddRange(UnityEngine.SceneManagement.SceneManager.GetSceneAt(i).GetRootGameObjects());
                        }
                        objects = SceneModeUtility.GetObjects(goRoots.ToArray(), true);
                    }

                    //using (new DebugTimer($"Fetching {gods.Length} Scene Objects Components"))
                    {
                        gods = new GOD[objects.Length];
                        for (int i = 0; i < objects.Length; ++i)
                        {
                            gods[i].gameObject = objects[i];
                            var id = gods[i].gameObject.GetInstanceID();
                            if (!componentsById.TryGetValue(id, out gods[i].name))
                            {
                                if (gods.Length > k_LODDetail2)
                                {
                                    gods[i].name = CleanString(gods[i].gameObject.name);
                                }
                                else if (gods.Length > k_LODDetail1)
                                {
                                    gods[i].name = CleanString(GetTransformPath(gods[i].gameObject.transform));
                                }
                                else
                                {
                                    gods[i].name = BuildComponents(gods[i].gameObject);
                                }
                                componentsById[id] = gods[i].name;
                            }
                        }

                        indexer = new SceneSearchIndexer(SceneManager.GetActiveScene().name, gods);
                        indexer.Build();
                    }
                }
            };

            onDisable = () =>
            {
                indexer = null;
                gods    = new GOD[0];
            };

            fetchItems = (context, items, provider) =>
            {
                if (gods == null)
                {
                    return;
                }

                if (indexer != null && indexer.IsReady())
                {
                    var results = indexer.Search(context.searchQuery).Take(201);
                    items.AddRange(results.Select(r =>
                    {
                        if (r.index < 0 || r.index >= gods.Length)
                        {
                            return(provider.CreateItem("invalid"));
                        }

                        var gameObjectId   = gods[r.index].gameObject.GetInstanceID().ToString();
                        var gameObjectName = gods[r.index].gameObject.name;
                        var itemScore      = r.score - 1000;
                        if (gameObjectName.Equals(context.searchQuery, StringComparison.InvariantCultureIgnoreCase))
                        {
                            itemScore *= 2;
                        }
                        var item = provider.CreateItem(gameObjectId, itemScore, null, null, null, r.index);
                        item.descriptionFormat = SearchItemDescriptionFormat.Ellipsis |
                                                 SearchItemDescriptionFormat.RightToLeft |
                                                 SearchItemDescriptionFormat.Highlight;
                        return(item);
                    }));
                }

                SearchGODs(context, provider, items);
            };

            fetchLabel = (item, context) =>
            {
                if (item.label != null)
                {
                    return(item.label);
                }

                var go = ObjectFromItem(item);
                if (!go)
                {
                    return(item.id);
                }

                var transformPath = GetTransformPath(go.transform);
                var components    = go.GetComponents <Component>();
                if (components.Length > 2 && components[1] && components[components.Length - 1])
                {
                    item.label = $"{transformPath} ({components[1].GetType().Name}..{components[components.Length-1].GetType().Name})";
                }
                else if (components.Length > 1 && components[1])
                {
                    item.label = $"{transformPath} ({components[1].GetType().Name})";
                }
                else
                {
                    item.label = $"{transformPath} ({item.id})";
                }

                long       score   = 1;
                List <int> matches = new List <int>();
                var        sq      = CleanString(context.searchQuery);
                if (FuzzySearch.FuzzyMatch(sq, CleanString(item.label), ref score, matches))
                {
                    item.label = RichTextFormatter.FormatSuggestionTitle(item.label, matches);
                }

                return(item.label);
            };

            fetchDescription = (item, context) =>
            {
                #if QUICKSEARCH_DEBUG
                item.description = gods[(int)item.data].name + " * " + item.score;
                #else
                var go = ObjectFromItem(item);
                item.description = GetHierarchyPath(go);
                #endif
                return(item.description);
            };

            fetchThumbnail = (item, context) =>
            {
                if (item.thumbnail)
                {
                    return(item.thumbnail);
                }

                var obj = ObjectFromItem(item);
                if (obj != null)
                {
                    if (SearchSettings.fetchPreview)
                    {
                        var assetPath = GetHierarchyAssetPath(obj, true);
                        if (!String.IsNullOrEmpty(assetPath))
                        {
                            item.thumbnail = AssetPreview.GetAssetPreview(obj);
                            if (item.thumbnail)
                            {
                                return(item.thumbnail);
                            }
                            item.thumbnail = Utils.GetAssetThumbnailFromPath(assetPath, true);
                            if (item.thumbnail)
                            {
                                return(item.thumbnail);
                            }
                        }
                    }

                    item.thumbnail = PrefabUtility.GetIconForGameObject(obj);
                    if (item.thumbnail)
                    {
                        return(item.thumbnail);
                    }
                    item.thumbnail = EditorGUIUtility.ObjectContent(obj, obj.GetType()).image as Texture2D;
                }

                return(item.thumbnail);
            };

            startDrag = (item, context) =>
            {
                var obj = ObjectFromItem(item);
                if (obj != null)
                {
                    DragAndDrop.PrepareStartDrag();
                    DragAndDrop.objectReferences = new[] { obj };
                    DragAndDrop.StartDrag("Drag scene object");
                }
            };

            trackSelection = (item, context) => PingItem(item);
        }