internal PrefabFamilyPopup(GameObject target)
        {
            if (isOpen)
            {
                throw new InvalidOperationException("PrefabFamilyPopup is already open");
            }

            this.m_Target = target;
            m_TargetPath  = AssetDatabase.GetAssetPath(target);
            m_TargetGUID  = AssetDatabase.AssetPathToGUID(m_TargetPath);

            k_MinNameWidth = k_MinWindowWidth - (k_TitleWidth + k_SplitWidth + k_OverridesWidth);

            m_SearchFilter = new SearchFilter()
            {
                classNames = new string[] { "Prefab" },
                searchArea = SearchFilter.SearchArea.AllAssets
            };
            m_Debounce = Delayer.Debounce(_ =>
            {
                SearchFilterChanged();
                editorWindow.Repaint();
            });

            Init();
        }
        void OnEnable()
        {
            hideFlags = HideFlags.DontSave;
            m_ShowOverlapPreview.valueChanged.AddListener(Repaint);
            m_ShowOverlapPreview.speed = 1.5f;
            m_ShowWidePreview.valueChanged.AddListener(Repaint);
            m_ShowWidePreview.speed = 1.5f;

            m_PreviewResizer.Init("ObjectPickerPreview");
            m_PreviewSize = m_PreviewResizer.GetPreviewSize(); // Init size

            if (s_GridAreaPriorityKeyboardEvents == null)
            {
                s_GridAreaPriorityKeyboardEvents = new HashSet <Event>
                {
                    Event.KeyboardEvent("up"),
                    Event.KeyboardEvent("down"),
                };
            }

            AssetPreview.ClearTemporaryAssetPreviews();

            SetupPreview();

            m_Debounce = Delayer.Debounce(_ =>
            {
                FilterSettingsChanged();
                Repaint();
            });
        }
        internal MaterialHierarchyPopup(Object[] targets, bool enabled, MaterialEditor materialEditor, Rect activatorRect)
        {
            this.enabled        = enabled;
            this.materialEditor = materialEditor;
            target     = targets[0] as Material;
            targetGUID = AssetDatabase.GUIDFromAssetPath(AssetDatabase.GetAssetPath(target));

            targetPositionY = singleLinePositionY = GUIUtility.GUIToScreenRect(activatorRect).yMax;
            if (target.isVariant || materialEditor.convertState == ConvertAction.Convert)
            {
                singleLinePositionY -= k_PositionShiftY;
            }

            k_MinNameWidth = k_MinWindowWidth - (k_TitleWidth + k_SplitWidth + k_OverridesWidth + k_LocksWidth);

            searchFilter = new SearchFilter()
            {
                classNames = new string[] { "Material" },
                searchArea = SearchFilter.SearchArea.AllAssets
            };
            debounce = Delayer.Debounce(_ =>
            {
                SearchFilterChanged();
                editorWindow.Repaint();
            });

            Init();
        }
        public void Init(
            Rect position,
            EditorWindow owner,
            UnityAction <TreeSelectorData> treeViewNeededCallback,
            UnityAction <TreeViewItem> selectionCallback,
            UnityAction doubleClickedCallback,
            int initialSelectedTreeViewItemID,
            int userData)
        {
            Clear();

            m_Owner = owner;

            m_TreeViewNeededEvent = new TreeViewNeededEvent();
            m_TreeViewNeededEvent.AddPersistentListener(treeViewNeededCallback, UnityEventCallState.EditorAndRuntime);

            m_SelectionEvent = new SelectionEvent();
            m_SelectionEvent.AddPersistentListener(selectionCallback, UnityEventCallState.EditorAndRuntime);

            m_DoubleClickedEvent = new DoubleClickedEvent();
            m_DoubleClickedEvent.AddPersistentListener(doubleClickedCallback, UnityEventCallState.EditorAndRuntime);

            m_OriginalSelectedID = initialSelectedTreeViewItemID;
            m_UserData           = userData;

            m_FocusSearchFilter = true; // start by focusing search field

            // Initial setup
            EnsureTreeViewIsValid(GetTreeViewRect(position));
            if (m_TreeView != null)
            {
                m_TreeView.SetSelection(new[] { m_OriginalSelectedID }, true);
                // If nothing is selected we expand all to better start overview. If we have a selection it has been revealed in SetSelection above
                if (m_OriginalSelectedID == 0)
                {
                    m_TreeView.data.SetExpandedWithChildren(m_TreeView.data.root, true);
                }
            }

            m_Debounce = Delayer.Debounce(context =>
            {
                DoSearchFilter();
                m_Owner.Repaint();
            });
        }
        internal MaterialHierarchyPopup(Material target, bool enabled, MaterialEditor materialEditor, Rect activatorRect)
        {
            this.enabled        = enabled;
            this.materialEditor = materialEditor;
            this.target         = target;
            targetGUID          = AssetDatabase.GUIDFromAssetPath(AssetDatabase.GetAssetPath(target));

            k_MinNameWidth = k_MinWindowWidth - (k_TitleWidth + k_SplitWidth + k_OverridesWidth + k_LocksWidth);

            searchFilter = new SearchFilter()
            {
                classNames = new string[] { "Material" },
                searchArea = SearchFilter.SearchArea.AllAssets
            };
            debounce = Delayer.Debounce(_ =>
            {
                SearchFilterChanged();
                editorWindow.Repaint();
            });

            Init();
        }
        internal MaterialHierarchyPopup(Object[] targets)
        {
            this.targets = targets;
            target       = targets[0] as Material;
            targetGUID   = AssetDatabase.GUIDFromAssetPath(AssetDatabase.GetAssetPath(target));

            k_MinNameWidth = k_MinWindowWidth - (k_TitleWidth + k_SplitWidth + k_OverridesWidth + k_LocksWidth);
            k_MaxNameWidth = k_MaxWindowWidth - (k_TitleWidth + k_SplitWidth + k_OverridesWidth + k_LocksWidth);

            convertState = ConvertAction.None;
            searchFilter = new SearchFilter()
            {
                classNames = new string[] { "Material" },
                searchArea = SearchFilter.SearchArea.AllAssets
            };
            debounce = Delayer.Debounce(_ =>
            {
                SearchFilterChanged();
                editorWindow.Repaint();
            });

            Init();
        }