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();
        }
        void OnDisable()
        {
            if (m_ObjectSelectorReceiver != null)
            {
                m_ObjectSelectorReceiver.OnSelectionClosed(GetCurrentObject());
            }

            if (m_OnObjectSelectorClosed != null)
            {
                m_OnObjectSelectorClosed(GetCurrentObject());
            }

            SendEvent(ObjectSelectorClosedCommand, false);
            if (m_ListArea != null)
            {
                m_StartGridSize.value = m_ListArea.gridSize;
            }

            Undo.CollapseUndoOperations(m_ModalUndoGroup);

            if (s_SharedObjectSelector == this)
            {
                s_SharedObjectSelector = null;
            }
            if (m_EditorCache != null)
            {
                m_EditorCache.Dispose();
            }

            AssetPreview.ClearTemporaryAssetPreviews();

            m_Debounce = null;
        }
        public void Clear()
        {
            m_Owner = null;
            m_TreeViewNeededEvent = null;
            m_SelectionEvent      = null;

            m_DoubleClickedEvent = null;
            m_OriginalSelectedID = 0;
            m_UserData           = 0;

            m_TreeView          = null;
            m_TreeViewState     = null;
            m_ErrorCounter      = 0;
            m_FocusSearchFilter = false;
            m_Debounce          = null;
        }
        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();
            });
        }
        void OnDisable()
        {
            NotifySelectorClosed(false);
            if (m_ListArea != null)
            {
                m_StartGridSize.value = m_ListArea.gridSize;
            }

            if (s_SharedObjectSelector == this)
            {
                s_SharedObjectSelector = null;
            }
            if (m_EditorCache != null)
            {
                m_EditorCache.Dispose();
            }

            AssetPreview.ClearTemporaryAssetPreviews();
            HierarchyProperty.ClearSceneObjectsFilter();
            m_Debounce?.Dispose();
            m_Debounce = null;
        }
        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();
        }
Esempio n. 9
0
        void OnDisable()
        {
            NotifySelectorClosed(false);
            if (m_ListArea != null)
            {
                m_StartGridSize.value = m_ListArea.gridSize;
            }

            Undo.CollapseUndoOperations(m_ModalUndoGroup);

            if (s_SharedObjectSelector == this)
            {
                s_SharedObjectSelector = null;
            }
            if (m_EditorCache != null)
            {
                m_EditorCache.Dispose();
            }

            AssetPreview.ClearTemporaryAssetPreviews();

            m_Debounce = null;
        }
        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();
        }