UnityEditor.PackageExportTreeView.OnGUI C# (CSharp) Method

OnGUI() public method

public OnGUI ( Rect rect ) : void
rect UnityEngine.Rect
return void
        public void OnGUI(Rect rect)
        {
            int controlID = GUIUtility.GetControlID(FocusType.Keyboard);
            this.m_TreeView.OnGUI(rect, controlID);
            if ((((Event.current.type == EventType.KeyDown) && (Event.current.keyCode == KeyCode.Space)) && ((this.m_Selection != null) && (this.m_Selection.Count > 0))) && (GUIUtility.keyboardControl == controlID))
            {
                EnabledState state = (this.m_Selection[0].enabledState == EnabledState.All) ? EnabledState.None : EnabledState.All;
                this.m_Selection[0].enabledState = state;
                this.ItemWasToggled(this.m_Selection[0]);
                Event.current.Use();
            }
        }

Usage Example

        private void TreeViewArea(bool showLoadingScreen)
        {
            Rect treeAreaRect = GUILayoutUtility.GetRect(1, 9999, 1, 99999);

            if (showLoadingScreen)
            {
                GUI.Label(treeAreaRect, "Loading...", Styles.loadingTextStyle);
                return;
            }

            if (m_ExportPackageItems != null && m_ExportPackageItems.Length > 0)
            {
                if (m_TreeViewState == null)
                {
                    m_TreeViewState = new TreeViewState();
                }

                if (m_Tree == null)
                {
                    m_Tree = new PackageExportTreeView(this, m_TreeViewState, new Rect());
                }

                m_Tree.OnGUI(treeAreaRect);
            }
        }