/// <summary>
        /// Build the GUI for the system window.
        /// </summary>
        void OnEnable()
        {
            titleContent = EditorGUIUtility.TrTextContent(k_WindowName, EditorIcons.System);
            minSize      = k_MinWindowSize;

            m_Root = new VisualElement {
                style = { flexGrow = 1 }
            };
            rootVisualElement.Add(m_Root);

            m_NoWorld = new CenteredMessageElement()
            {
                Message = NoWorldMessageContent
            };
            rootVisualElement.Add(m_NoWorld);
            m_NoWorld.Hide();

            m_State = SessionState <State> .GetOrCreate($"{typeof(SystemScheduleWindow).FullName}+{nameof(State)}+{EditorWindowInstanceKey}");

            Resources.Templates.SystemSchedule.AddStyles(m_Root);
            Resources.Templates.DotsEditorCommon.AddStyles(m_Root);

            CreateToolBar(m_Root);
            CreateTreeViewHeader(m_Root);
            CreateTreeView(m_Root);

            PlayerLoopSystemGraph.Register();

            m_SearchElement.Search(SearchFilter);

            PlayerLoopSystemGraph.OnGraphChanged      += RebuildTreeView;
            SystemDetailsVisualElement.OnAddFilter    += OnAddFilter;
            SystemDetailsVisualElement.OnRemoveFilter += OnRemoveFilter;
        }
Example #2
0
        void OnEnable()
        {
            titleContent = new GUIContent(k_WindowName, EditorIcons.EntityGroup);
            minSize      = k_MinWindowSize;

            m_Root = new VisualElement {
                style = { flexGrow = 1 }
            };
            rootVisualElement.Add(m_Root);

            m_NoWorld = new CenteredMessageElement()
            {
                Message = NoWorldMessageContent
            };
            rootVisualElement.Add(m_NoWorld);
            m_NoWorld.Hide();

            Resources.Templates.CommonResources.AddStyles(m_Root);
            Resources.Templates.DotsEditorCommon.AddStyles(m_Root);
            m_Root.AddToClassList(UssClasses.Resources.EntityHierarchy);

            CreateToolbar();
            m_EntityHierarchy = new EntityHierarchy(new EntityHierarchyFoldingState(EditorWindowInstanceKey));
            m_Root.Add(m_EntityHierarchy);
            CreateEnableLiveLinkMessage();

            m_EntityHierarchy.Refresh(this);

            m_SearchElement.Search(SearchFilter);

            LiveLinkConfigHelper.LiveLinkEnabledChanged += UpdateEnableLiveLinkMessage;
            EditorApplication.playModeStateChanged      += UpdateEnableLiveLinkMessage;
        }
        /// <summary>
        /// Constructor of the tree view.
        /// </summary>
        public SystemTreeView(string editorWindowInstanceKey)
        {
            m_SystemTreeView = new TreeView(m_TreeViewRootItems, Constants.ListView.ItemHeight, MakeTreeViewItem, ReleaseTreeViewItem, BindTreeViewItem)
            {
                viewDataKey   = $"{Constants.State.ViewDataKeyPrefix}{typeof(SystemScheduleWindow).FullName}+{editorWindowInstanceKey}",
                selectionType = SelectionType.Single,
                name          = "SystemTreeView",
                style         = { flexGrow = 1 }
            };

            m_SystemTreeView.RegisterCallback <GeometryChangedEvent>(evt =>
            {
                if (m_ScrollToItemId == -1)
                {
                    return;
                }

                var tempId       = m_ScrollToItemId;
                m_ScrollToItemId = -1;
                if (m_SystemTreeView.FindItem(tempId) != null)
                {
                    m_SystemTreeView.ScrollToItem(tempId);
                }
            });

            m_SystemTreeView.onSelectionChange += OnSelectionChanged;
            Add(m_SystemTreeView);

            m_SystemDetailsVisualElement = new SystemDetailsVisualElement();

            m_SearchEmptyMessage = new CenteredMessageElement {
                Title = k_NoSystemsFoundTitle
            };
            m_SearchEmptyMessage.Hide();
            Add(m_SearchEmptyMessage);

            // Create list view for search results.
            m_SystemListView = new ListView(m_ListViewFilteredItems, Constants.ListView.ItemHeight, MakeListViewItem, ReleaseListViewItem, BindListViewItem)
            {
                selectionType = SelectionType.Single,
                name          = "SystemListView",
                style         = { flexGrow = 1 }
            };
            m_SystemListView.RegisterCallback <PointerDownEvent>(evt =>
            {
                if (evt.button == (int)MouseButton.LeftMouse)
                {
                    Selection.activeObject = null;
                }
            });

#if UNITY_2020_1_OR_NEWER
            m_SystemListView.onSelectionChange += OnSelectionChanged;
#else
            m_SystemListView.onSelectionChanged += OnSelectionChanged;
#endif

            Add(m_SystemListView);
        }
Example #4
0
        public EntityHierarchy(EntityHierarchyFoldingState entityHierarchyFoldingState)
        {
            m_EntityHierarchyFoldingState = entityHierarchyFoldingState;

            style.flexGrow  = 1.0f;
            m_ViewContainer = new VisualElement();
            m_ViewContainer.style.flexGrow = 1.0f;
            m_ViewContainer.RegisterCallback <PointerDownEvent>(evt =>
            {
                if (evt.button == (int)MouseButton.LeftMouse)
                {
                    Selection.activeObject = null;
                }
            });
            m_TreeView = new TreeView(m_TreeViewRootItems, Constants.ListView.ItemHeight, MakeTreeViewItem, ReleaseTreeViewItem, BindTreeViewItem)
            {
                selectionType = SelectionType.Single,
                name          = Constants.EntityHierarchy.FullViewName,
                style         = { flexGrow = 1 },
            };
            m_TreeView.onSelectionChange         += OnLocalSelectionChanged;
            m_TreeView.ItemExpandedStateChanging += (item, isExpanding) =>
            {
                var entityHierarchyItem = (EntityHierarchyItem)item;
                if (entityHierarchyItem.NodeId.Kind == NodeKind.Scene || entityHierarchyItem.NodeId.Kind == NodeKind.SubScene)
                {
                    m_EntityHierarchyFoldingState.OnFoldingStateChanged(entityHierarchyItem.NodeId, isExpanding);
                }
            };
            m_TreeView.Hide();
            m_ViewContainer.Add(m_TreeView);

            m_ListView = new ListView(m_ListViewFilteredItems, Constants.ListView.ItemHeight, MakeListViewItem, ReleaseListViewItem, BindListViewItem)
            {
                selectionType = SelectionType.Single,
                name          = Constants.EntityHierarchy.SearchViewName,
                style         = { flexGrow = 1 }
            };

            m_ListView.Hide();
            m_ViewContainer.Add(m_ListView);

            m_SearchEmptyMessage = new CenteredMessageElement();
            m_SearchEmptyMessage.Hide();
            Add(m_SearchEmptyMessage);

#if UNITY_2020_1_OR_NEWER
            m_ListView.onSelectionChange += OnLocalSelectionChanged;
#else
            m_ListView.onSelectionChanged += OnSelectionChanged;
#endif

            m_ItemsCache = new HierarchyItemsCache();

            m_CurrentViewMode = ViewMode.Full;

            Add(m_ViewContainer);
            Selection.selectionChanged += OnGlobalSelectionChanged;
        }