コード例 #1
0
            public TestNode AddChild(EntityHierarchyNodeId childrenNodeId)
            {
                var childrenNode = new TestNode(m_TestHierarchy, childrenNodeId);

                Children.Add(childrenNode);
                return(childrenNode);
            }
        public IEnumerator Search_QuerySearch_IncludeSpecialEntity([Values(typeof(Prefab), typeof(Disabled))] Type componentType)
        {
            SceneManager.MoveGameObjectToScene(new GameObject("go"), m_SubScene.EditingScene);

            yield return(UpdateLiveLink());

            var e = m_Manager.CreateEntity();

            m_Manager.SetName(e, "Test entity");
            m_Manager.AddComponent <EntityGuid>(e);
            m_Manager.AddComponent(e, componentType);

            yield return(SkipAnEditorFrameAndDiffingUtility());

            var treeview     = WindowRoot.Q <TreeView>(Constants.EntityHierarchy.FullViewName);
            var expectedNode = EntityHierarchyNodeId.FromEntity(e);

            Assert.That(treeview.items.Cast <EntityHierarchyItem>().Select(i => i.NodeId), Does.Contain(expectedNode));

            var searchField = WindowRoot.Q <SearchElement>();

            searchField.Search($"c:{typeof(EntityGuid).FullName}");

            yield return(SkipAnEditorFrameAndDiffingUtility());

            var listview = WindowRoot.Q <ListView>(Constants.EntityHierarchy.SearchViewName);

            Assert.That(listview.itemsSource.Cast <EntityHierarchyItem>().Select(i => i.NodeId), Does.Contain(expectedNode));
        }
コード例 #3
0
        public void ShouldPersistState()
        {
            var subSceneA       = EntityHierarchyNodeId.FromSubScene(1);
            var subSceneB       = EntityHierarchyNodeId.FromSubScene(2);
            var unknownSubScene = EntityHierarchyNodeId.FromSubScene(3);

            EntityHierarchyState.OnFoldingStateChanged(subSceneA, true);
            EntityHierarchyState.OnFoldingStateChanged(subSceneB, false);

            Assert.That(EntityHierarchyState.GetFoldingState(subSceneA), Is.True);
            Assert.That(EntityHierarchyState.GetFoldingState(subSceneB), Is.False);
            Assert.That(EntityHierarchyState.GetFoldingState(unknownSubScene), Is.Null);
        }
コード例 #4
0
        public void ShouldPersistState()
        {
            var state = new EntityHierarchyFoldingState(Guid.NewGuid().ToString("N"));

            var subSceneA       = EntityHierarchyNodeId.FromSubScene(1);
            var subSceneB       = EntityHierarchyNodeId.FromSubScene(2);
            var unknownSubScene = EntityHierarchyNodeId.FromSubScene(3);

            state.OnFoldingStateChanged(subSceneA, true);
            state.OnFoldingStateChanged(subSceneB, false);

            Assert.That(state.GetFoldingState(subSceneA), Is.True);
            Assert.That(state.GetFoldingState(subSceneB), Is.False);
            Assert.That(state.GetFoldingState(unknownSubScene), Is.Null);
        }
コード例 #5
0
        public void ShouldIgnoreEverythingExceptSceneAndSubScenes()
        {
            EntityHierarchyState.OnFoldingStateChanged(EntityHierarchyNodeId.Root, true);
            EntityHierarchyState.OnFoldingStateChanged(EntityHierarchyNodeId.FromEntity(new Entity {
                Index = 1, Version = 1
            }), true);
            EntityHierarchyState.OnFoldingStateChanged(EntityHierarchyNodeId.FromScene(1), true);
            EntityHierarchyState.OnFoldingStateChanged(EntityHierarchyNodeId.FromSubScene(1), false);

            Assert.That(EntityHierarchyState.GetFoldingState(EntityHierarchyNodeId.Root), Is.Null);
            Assert.That(EntityHierarchyState.GetFoldingState(EntityHierarchyNodeId.FromEntity(new Entity {
                Index = 1, Version = 1
            })), Is.Null);
            Assert.That(EntityHierarchyState.GetFoldingState(EntityHierarchyNodeId.FromScene(1)), Is.True);
            Assert.That(EntityHierarchyState.GetFoldingState(EntityHierarchyNodeId.FromSubScene(1)), Is.False);
        }
        // Creates the basic hierarchy for a single scene with a single subscene.
        static (TestHierarchy.TestNode root, TestHierarchy.TestNode subScene, int nextSceneId, int nextEntityId) CreateBaseHierarchyForSubscene()
        {
            var entityId = 0;
            var sceneId  = 0;

            var rootNode = TestHierarchy.CreateRoot();

            rootNode.AddChildren(
                new EntityHierarchyNodeId(NodeKind.Entity, entityId++, 0),                                  // World Time Entity
                new EntityHierarchyNodeId(NodeKind.Entity, entityId++, 0),                                  // SubScene Entity
                new EntityHierarchyNodeId(NodeKind.Entity, entityId++, 0));                                 // SceneSection Entity

            var subSceneNode =
                rootNode.AddChild(EntityHierarchyNodeId.FromScene(sceneId++))                  // Main Scene
                .AddChild(EntityHierarchyNodeId.FromSubScene(sceneId++));                      // SubScene

            return(rootNode, subSceneNode, sceneId, entityId);
        }
コード例 #7
0
        public void ShouldIgnoreEverythingExceptSceneAndSubScenes()
        {
            var state = new EntityHierarchyFoldingState(Guid.NewGuid().ToString("N"));

            state.OnFoldingStateChanged(EntityHierarchyNodeId.Root, true);
            state.OnFoldingStateChanged(EntityHierarchyNodeId.FromEntity(new Entity {
                Index = 1, Version = 1
            }), true);
            state.OnFoldingStateChanged(EntityHierarchyNodeId.FromScene(1), true);
            state.OnFoldingStateChanged(EntityHierarchyNodeId.FromSubScene(1), false);

            Assert.That(state.GetFoldingState(EntityHierarchyNodeId.Root), Is.Null);
            Assert.That(state.GetFoldingState(EntityHierarchyNodeId.FromEntity(new Entity {
                Index = 1, Version = 1
            })), Is.Null);
            Assert.That(state.GetFoldingState(EntityHierarchyNodeId.FromScene(1)), Is.True);
            Assert.That(state.GetFoldingState(EntityHierarchyNodeId.FromSubScene(1)), Is.False);
        }
コード例 #8
0
        internal void WriteActualStrategyTree(StringBuilder errorMessage, EntityHierarchyNodeId nodeId, int indent, bool kindOnly = false)
        {
            errorMessage.Append(' ', indent);
            errorMessage.Append("- ");
            errorMessage.AppendLine(kindOnly ? nodeId.Kind.ToString() : nodeId.ToString());

            if (!m_HierarchyState.HasChildren(nodeId))
            {
                return;
            }
            indent++;

            var children = m_HierarchyState.GetChildren(nodeId, Allocator.Temp);

            foreach (var child in children.OrderBy(x => x))
            {
                WriteActualStrategyTree(errorMessage, child, indent, kindOnly);
            }

            children.Dispose();
        }
        public IEnumerator Selection_DestroyingSelectedEntityDeselectInView()
        {
            var internalListView = WindowRoot.Q <TreeView>(Constants.EntityHierarchy.FullViewName).Q <ListView>();

            var e    = m_Manager.CreateEntity();
            var node = EntityHierarchyNodeId.FromEntity(e);

            yield return(SkipAnEditorFrameAndDiffingUtility());

            Assert.That(internalListView.currentSelectionIds, Is.Empty);

            EntitySelectionProxy.SelectEntity(m_Manager.World, e);
            yield return(null);

            Assert.That(internalListView.currentSelectionIds, Is.EquivalentTo(new[] { node.GetHashCode() }));

            m_Manager.DestroyEntity(e);
            yield return(SkipAnEditorFrameAndDiffingUtility());

            Assert.That(internalListView.selectedItems, Is.Empty);
        }
コード例 #10
0
 public bool Equals(EntityHierarchyNodeId other) => other.Equals(NodeId);
コード例 #11
0
 public TestNode AddChild(Entity entity)
 => AddChild(EntityHierarchyNodeId.FromEntity(entity));
コード例 #12
0
 public TestNode(TestHierarchy testHierarchy, EntityHierarchyNodeId nodeId)
 => (m_TestHierarchy, NodeId) = (testHierarchy, nodeId);