Esempio n. 1
0
 private void UpdateSearch()
 {
     Search();
     _wantSearch = false;
     _resultScrollbarPosition = Vector2.zero;
     _selectedListing         = null;
 }
Esempio n. 2
0
    private void GetSceneGameObjects()
    {
        GameObject[] sceneGameObjects = FindObjectsOfType <GameObject>();

        _sceneListings = new GameObjectListing[sceneGameObjects.Length];
        for (int i = 0; i < sceneGameObjects.Length; i++)
        {
            _sceneListings[i] = new GameObjectListing(sceneGameObjects[i]);
        }
    }
Esempio n. 3
0
    private void DrawResults()
    {
        EditorGUILayout.Space();

        if (GUILayout.Button(new GUIContent(string.Format("Results ({0})", _results.Count)), EditorStyles.toolbarButton))
        {
            _foldoutResults = !_foldoutResults;
        }

        if (_foldoutResults)
        {
            DrawSearchButton();

            _resultScrollbarPosition = GUILayout.BeginScrollView(_resultScrollbarPosition);

            EditorGUI.indentLevel++;

            var        style        = EditorStyles.toolbarButton;
            Color      oldTextColor = new Color(style.normal.textColor.r, style.normal.textColor.g, style.normal.textColor.b);
            TextAnchor oldAlignment = style.alignment;
            style.alignment = TextAnchor.MiddleLeft;
            foreach (var listing in _results)
            {
                style.normal.textColor = listing.Color;
                if (_selectedListing != null && listing == _selectedListing)
                {
                    style.normal.textColor = Color.white;
                }
                if (GUILayout.Button(listing.GameObject.name, style))
                {
                    _selectedListing = listing;

                    GameObject target = Event.current.button == 1 ? listing.GetRootGameObject() : listing.GameObject;
                    Selection.activeGameObject = target;
                    EditorGUIUtility.PingObject(target);
                }
            }
            style.normal.textColor = oldTextColor;
            style.alignment        = oldAlignment;

            EditorGUI.indentLevel--;

            GUILayout.EndScrollView();

            if (Event.current.type == EventType.Repaint)
            {
                _scrollHeight = GUILayoutUtility.GetLastRect().height;
            }
        }
    }