Inheritance: UnityEditor.TreeViewGUI
Esempio n. 1
0
        private void Init()
        {
            if (this.m_TreeView != null)
            {
                return;
            }
            if (this.m_TreeViewState == null)
            {
                this.m_TreeViewState = new TreeViewState();
            }
            this.m_TreeView = new TreeView(this, this.m_TreeViewState);
            TreeView expr_3A = this.m_TreeView;

            expr_3A.itemDoubleClickedCallback = (Action <int>)Delegate.Combine(expr_3A.itemDoubleClickedCallback, new Action <int>(this.TreeViewItemDoubleClicked));
            TreeView expr_61 = this.m_TreeView;

            expr_61.selectionChangedCallback = (Action <int[]>)Delegate.Combine(expr_61.selectionChangedCallback, new Action <int[]>(this.TreeViewSelectionChanged));
            TreeView expr_88 = this.m_TreeView;

            expr_88.onGUIRowCallback = (Action <int, Rect>)Delegate.Combine(expr_88.onGUIRowCallback, new Action <int, Rect>(this.OnGUIAssetCallback));
            TreeView expr_AF = this.m_TreeView;

            expr_AF.dragEndedCallback = (Action <int[], bool>)Delegate.Combine(expr_AF.dragEndedCallback, new Action <int[], bool>(this.OnDragEndedCallback));
            this.m_TreeView.deselectOnUnhandledMouseDown = true;
            GameObjectTreeViewDataSource gameObjectTreeViewDataSource = new GameObjectTreeViewDataSource(this.m_TreeView, 0, false, false);
            GameObjectsTreeViewDragging  dragging = new GameObjectsTreeViewDragging(this.m_TreeView);
            GameObjectTreeViewGUI        gui      = new GameObjectTreeViewGUI(this.m_TreeView, false);

            this.m_TreeView.Init(this.treeViewRect, gameObjectTreeViewDataSource, gui, dragging);
            gameObjectTreeViewDataSource.searchMode   = (int)this.m_SearchMode;
            gameObjectTreeViewDataSource.searchString = this.m_SearchFilter;
            this.m_AllowAlphaNumericalSort            = (EditorPrefs.GetBool("AllowAlphaNumericHierarchy", false) || InternalEditorUtility.inBatchMode);
            this.SetUpSortMethodLists();
            this.m_TreeView.ReloadData();
        }
        private void Init()
        {
            if (this.m_TreeViewState == null)
            {
                this.m_TreeViewState = new TreeViewState();
            }
            this.m_TreeView = new TreeView((EditorWindow)this, this.m_TreeViewState);
            this.m_TreeView.itemDoubleClickedCallback        += new System.Action <int>(this.TreeViewItemDoubleClicked);
            this.m_TreeView.selectionChangedCallback         += new System.Action <int[]>(this.TreeViewSelectionChanged);
            this.m_TreeView.onGUIRowCallback                 += new System.Action <int, Rect>(this.OnGUIAssetCallback);
            this.m_TreeView.dragEndedCallback                += new System.Action <int[], bool>(this.OnDragEndedCallback);
            this.m_TreeView.contextClickItemCallback         += new System.Action <int>(this.ItemContextClick);
            this.m_TreeView.contextClickOutsideItemsCallback += new System.Action(this.ContextClickOutsideItems);
            this.m_TreeView.deselectOnUnhandledMouseDown      = true;
            GameObjectTreeViewDataSource treeViewDataSource = new GameObjectTreeViewDataSource(this.m_TreeView, this.m_CurrenRootInstanceID, false, false);
            GameObjectsTreeViewDragging  treeViewDragging   = new GameObjectsTreeViewDragging(this.m_TreeView);
            GameObjectTreeViewGUI        objectTreeViewGui  = new GameObjectTreeViewGUI(this.m_TreeView, false);

            this.m_TreeView.Init(this.treeViewRect, (ITreeViewDataSource)treeViewDataSource, (ITreeViewGUI)objectTreeViewGui, (ITreeViewDragging)treeViewDragging);
            treeViewDataSource.searchMode   = (int)this.m_SearchMode;
            treeViewDataSource.searchString = this.m_SearchFilter;
            this.m_AllowAlphaNumericalSort  = EditorPrefs.GetBool("AllowAlphaNumericHierarchy", false) || InternalEditorUtility.inBatchMode;
            this.SetUpSortMethodLists();
            this.m_TreeView.ReloadData();
        }
        protected void DoAdditionalSceneHeaderGUI(GameObjectTreeViewItem goItem, Rect rect)
        {
            Rect position = new Rect(rect.width - 16f - 4f, rect.y + (rect.height - 6f) * 0.5f, 16f, rect.height);

            if (Event.current.type == EventType.Repaint)
            {
                GameObjectTreeViewGUI.GameObjectStyles.optionsButtonStyle.Draw(position, false, false, false, false);
            }
            position.y      = rect.y;
            position.height = rect.height;
            position.width  = 24f;
            if (EditorGUI.DropdownButton(position, GUIContent.none, FocusType.Passive, GUIStyle.none))
            {
                this.m_TreeView.SelectionClick(goItem, true);
                this.m_TreeView.contextClickItemCallback(goItem.id);
            }
            if (GameObjectTreeViewGUI.OnPostHeaderGUI != null)
            {
                float num           = rect.width - position.x;
                float width         = rect.width - num - 4f;
                float x             = 0f;
                float y             = rect.y;
                float height        = rect.height;
                Rect  availableRect = new Rect(x, y, width, height);
                GameObjectTreeViewGUI.OnPostHeaderGUI(availableRect, goItem.scene.path);
            }
        }
        public override void OnInitialize()
        {
            base.OnInitialize();
            GameObjectTreeViewGUI gameObjectTreeViewGUI = (GameObjectTreeViewGUI)this.m_TreeView.gui;

            gameObjectTreeViewGUI.scrollHeightChanged   += new Action(this.EnsureFullyInitialized);
            gameObjectTreeViewGUI.scrollPositionChanged += new Action(this.EnsureFullyInitialized);
            gameObjectTreeViewGUI.mouseAndKeyboardInput += new Action(this.EnsureFullyInitialized);
        }
        public override void OnInitialize()
        {
            base.OnInitialize();
            GameObjectTreeViewGUI gui = (GameObjectTreeViewGUI)this.m_TreeView.gui;

            gui.scrollHeightChanged     += new System.Action(this.EnsureFullyInitialized);
            gui.scrollPositionChanged   += new System.Action(this.EnsureFullyInitialized);
            gui.mouseDownInTreeViewRect += new System.Action(this.EnsureFullyInitialized);
        }
Esempio n. 6
0
        public override void OnInitialize()
        {
            base.OnInitialize();
            GameObjectTreeViewGUI gui = (GameObjectTreeViewGUI)base.m_TreeView.gui;

            gui.scrollHeightChanged     = (Action)Delegate.Combine(gui.scrollHeightChanged, new Action(this.EnsureFullyInitialized));
            gui.scrollPositionChanged   = (Action)Delegate.Combine(gui.scrollPositionChanged, new Action(this.EnsureFullyInitialized));
            gui.mouseDownInTreeViewRect = (Action)Delegate.Combine(gui.mouseDownInTreeViewRect, new Action(this.EnsureFullyInitialized));
        }
        public override void OnInitialize()
        {
            base.OnInitialize();
            GameObjectTreeViewGUI gameObjectTreeViewGUI = (GameObjectTreeViewGUI)this.m_TreeView.gui;
            GameObjectTreeViewGUI expr_18 = gameObjectTreeViewGUI;

            expr_18.scrollHeightChanged = (Action)Delegate.Combine(expr_18.scrollHeightChanged, new Action(this.EnsureFullyInitialized));
            GameObjectTreeViewGUI expr_3A = gameObjectTreeViewGUI;

            expr_3A.scrollPositionChanged = (Action)Delegate.Combine(expr_3A.scrollPositionChanged, new Action(this.EnsureFullyInitialized));
            GameObjectTreeViewGUI expr_5C = gameObjectTreeViewGUI;

            expr_5C.mouseDownInTreeViewRect = (Action)Delegate.Combine(expr_5C.mouseDownInTreeViewRect, new Action(this.EnsureFullyInitialized));
        }
        private void Init()
        {
            if (this.m_TreeViewState == null)
            {
                this.m_TreeViewState = new TreeViewState();
            }
            this.m_TreeView = new TreeView(this, this.m_TreeViewState);
            TreeView expr_2E = this.m_TreeView;

            expr_2E.itemDoubleClickedCallback = (Action <int>)Delegate.Combine(expr_2E.itemDoubleClickedCallback, new Action <int>(this.TreeViewItemDoubleClicked));
            TreeView expr_55 = this.m_TreeView;

            expr_55.selectionChangedCallback = (Action <int[]>)Delegate.Combine(expr_55.selectionChangedCallback, new Action <int[]>(this.TreeViewSelectionChanged));
            TreeView expr_7C = this.m_TreeView;

            expr_7C.onGUIRowCallback = (Action <int, Rect>)Delegate.Combine(expr_7C.onGUIRowCallback, new Action <int, Rect>(this.OnGUIAssetCallback));
            TreeView expr_A3 = this.m_TreeView;

            expr_A3.dragEndedCallback = (Action <int[], bool>)Delegate.Combine(expr_A3.dragEndedCallback, new Action <int[], bool>(this.OnDragEndedCallback));
            TreeView expr_CA = this.m_TreeView;

            expr_CA.contextClickItemCallback = (Action <int>)Delegate.Combine(expr_CA.contextClickItemCallback, new Action <int>(this.ItemContextClick));
            TreeView expr_F1 = this.m_TreeView;

            expr_F1.contextClickOutsideItemsCallback     = (Action)Delegate.Combine(expr_F1.contextClickOutsideItemsCallback, new Action(this.ContextClickOutsideItems));
            this.m_TreeView.deselectOnUnhandledMouseDown = true;
            bool showRootNode          = false;
            bool rootNodeIsCollapsable = false;
            GameObjectTreeViewDataSource gameObjectTreeViewDataSource = new GameObjectTreeViewDataSource(this.m_TreeView, this.m_CurrenRootInstanceID, showRootNode, rootNodeIsCollapsable);
            GameObjectsTreeViewDragging  dragging = new GameObjectsTreeViewDragging(this.m_TreeView);
            GameObjectTreeViewGUI        gui      = new GameObjectTreeViewGUI(this.m_TreeView, false);

            this.m_TreeView.Init(this.treeViewRect, gameObjectTreeViewDataSource, gui, dragging);
            gameObjectTreeViewDataSource.searchMode   = (int)this.m_SearchMode;
            gameObjectTreeViewDataSource.searchString = this.m_SearchFilter;
            this.m_AllowAlphaNumericalSort            = (EditorPrefs.GetBool("AllowAlphaNumericHierarchy", false) || InternalEditorUtility.inBatchMode);
            this.SetUpSortMethodLists();
            this.m_TreeView.ReloadData();
        }
		private void Init()
		{
			if (this.m_TreeView != null)
			{
				return;
			}
			if (this.m_TreeViewState == null)
			{
				this.m_TreeViewState = new TreeViewState();
			}
			this.m_TreeView = new TreeView(this, this.m_TreeViewState);
			TreeView expr_3A = this.m_TreeView;
			expr_3A.itemDoubleClickedCallback = (Action<int>)Delegate.Combine(expr_3A.itemDoubleClickedCallback, new Action<int>(this.TreeViewItemDoubleClicked));
			TreeView expr_61 = this.m_TreeView;
			expr_61.selectionChangedCallback = (Action<int[]>)Delegate.Combine(expr_61.selectionChangedCallback, new Action<int[]>(this.TreeViewSelectionChanged));
			TreeView expr_88 = this.m_TreeView;
			expr_88.onGUIRowCallback = (Action<int, Rect>)Delegate.Combine(expr_88.onGUIRowCallback, new Action<int, Rect>(this.OnGUIAssetCallback));
			TreeView expr_AF = this.m_TreeView;
			expr_AF.dragEndedCallback = (Action<int[], bool>)Delegate.Combine(expr_AF.dragEndedCallback, new Action<int[], bool>(this.OnDragEndedCallback));
			this.m_TreeView.deselectOnUnhandledMouseDown = true;
			GameObjectTreeViewDataSource gameObjectTreeViewDataSource = new GameObjectTreeViewDataSource(this.m_TreeView, 0, false, false);
			GameObjectsTreeViewDragging dragging = new GameObjectsTreeViewDragging(this.m_TreeView);
			GameObjectTreeViewGUI gui = new GameObjectTreeViewGUI(this.m_TreeView, false);
			this.m_TreeView.Init(this.treeViewRect, gameObjectTreeViewDataSource, gui, dragging);
			gameObjectTreeViewDataSource.searchMode = (int)this.m_SearchMode;
			gameObjectTreeViewDataSource.searchString = this.m_SearchFilter;
			this.m_AllowAlphaNumericalSort = (EditorPrefs.GetBool("AllowAlphaNumericHierarchy", false) || InternalEditorUtility.inBatchMode);
			this.SetUpSortMethodLists();
			this.m_TreeView.ReloadData();
		}
 private void Init()
 {
   if (this.m_TreeViewState == null)
     this.m_TreeViewState = new TreeViewState();
   this.m_TreeView = new TreeView((EditorWindow) this, this.m_TreeViewState);
   this.m_TreeView.itemDoubleClickedCallback += new System.Action<int>(this.TreeViewItemDoubleClicked);
   this.m_TreeView.selectionChangedCallback += new System.Action<int[]>(this.TreeViewSelectionChanged);
   this.m_TreeView.onGUIRowCallback += new System.Action<int, Rect>(this.OnGUIAssetCallback);
   this.m_TreeView.dragEndedCallback += new System.Action<int[], bool>(this.OnDragEndedCallback);
   this.m_TreeView.contextClickItemCallback += new System.Action<int>(this.ItemContextClick);
   this.m_TreeView.contextClickOutsideItemsCallback += new System.Action(this.ContextClickOutsideItems);
   this.m_TreeView.deselectOnUnhandledMouseDown = true;
   GameObjectTreeViewDataSource treeViewDataSource = new GameObjectTreeViewDataSource(this.m_TreeView, this.m_CurrenRootInstanceID, false, false);
   GameObjectsTreeViewDragging treeViewDragging = new GameObjectsTreeViewDragging(this.m_TreeView);
   GameObjectTreeViewGUI objectTreeViewGui = new GameObjectTreeViewGUI(this.m_TreeView, false);
   this.m_TreeView.Init(this.treeViewRect, (ITreeViewDataSource) treeViewDataSource, (ITreeViewGUI) objectTreeViewGui, (ITreeViewDragging) treeViewDragging);
   treeViewDataSource.searchMode = (int) this.m_SearchMode;
   treeViewDataSource.searchString = this.m_SearchFilter;
   this.m_AllowAlphaNumericalSort = EditorPrefs.GetBool("AllowAlphaNumericHierarchy", false) || InternalEditorUtility.inBatchMode;
   this.SetUpSortMethodLists();
   this.m_TreeView.ReloadData();
 }
        public void StageHeaderGUI(Rect rect)
        {
            var stage = currentStage;

            if (stage == null || !stage.isValid)
            {
                return;
            }

            if (m_StageHeaderContent == null || m_StageHeaderContent == GUIContent.none || m_LastStageUnsavedChangesState == stage.hasUnsavedChanges)
            {
                CacheStageHeaderContent();
            }
            m_LastStageUnsavedChangesState = stage.hasUnsavedChanges;

            // Background
            GUI.Box(rect, GUIContent.none, Styles.stageHeaderBg);

            Rect interactionRect = new Rect(
                rect.x,
                rect.y,
                Styles.leftArrow.fixedWidth + Styles.leftArrow.margin.horizontal,
                rect.height - 1); /*bottom borer*/

            // Back button
            if (Event.current.type == EventType.Repaint)
            {
                // Resets the fixed size to stretch the button
                float oldW = Styles.leftArrow.fixedWidth, oldH = Styles.leftArrow.fixedHeight;

                Styles.leftArrow.fixedWidth = 0; Styles.leftArrow.fixedHeight = 0;
                Styles.leftArrow.Draw(interactionRect, GUIContent.none, interactionRect.Contains(Event.current.mousePosition), false, false, false);
                Styles.leftArrow.fixedWidth = oldW; Styles.leftArrow.fixedHeight = oldH;
            }

            if (GUI.Button(interactionRect, GUIContent.none, GUIStyle.none))
            {
                StageNavigationManager.instance.NavigateBack(StageNavigationManager.Analytics.ChangeType.NavigateBackViaHierarchyHeaderLeftArrow);
            }

            // Options button
            Rect optionsButtonRect = new Rect();

            if (stage.showOptionsButton)
            {
                if (GameObjectTreeViewGUI.DoOptionsButton(rect, out optionsButtonRect))
                {
                    ShowStageContextMenu(stage);
                }
            }

            // Icon and name (and context click on background)
            EditorGUIUtility.SetIconSize(new Vector2(16, 16));
            float contentWidth    = TreeViewGUI.Styles.lineBoldStyle.CalcSize(m_StageHeaderContent).x;
            float xStart          = Styles.leftArrow.margin.left + Styles.leftArrow.fixedWidth;
            float space           = (optionsButtonRect.width > 0 ? optionsButtonRect.xMin : rect.width) - xStart;
            float offsetFromStart = xStart + Mathf.Max(0, (space - contentWidth) / 2);
            Rect  labelRect       = new Rect(offsetFromStart, rect.y + 2, space, 20);

            if (GUI.Button(labelRect, m_StageHeaderContent, stage.isAssetMissing ? BreadcrumbBar.DefaultStyles.labelBoldMissing : BreadcrumbBar.DefaultStyles.labelBold))
            {
                Event evt = Event.current;
                if (evt.button == 0)
                {
                    EditorGUIUtility.PingObject(AssetDatabase.LoadMainAssetAtPath(stage.assetPath));
                }
                else if (evt.button == 1)
                {
                    ShowStageContextMenu(stage);
                }
            }
            EditorGUIUtility.SetIconSize(Vector2.zero);

            // Version control overlay icons
            if (VersionControlUtils.isVersionControlConnected && EditorUserSettings.hierarchyOverlayIcons)
            {
                Rect overlayRect = labelRect;
                overlayRect.width  = 16;
                overlayRect.y     += (overlayRect.height - 16) / 2;
                overlayRect.height = 16;

                // The source asset could have been deleted while open inside the stage so the library object might be null here (case 1086613)
                var asset = AssetDatabase.LoadMainAssetAtPath(stage.assetPath);
                if (asset != null)
                {
                    AssetsTreeViewGUI.OnIconOverlayGUI(asset.GetInstanceID(), overlayRect, true);
                }
            }
        }