public IEnumerator ModelWithChildInScene1_MoveToScene2_ModelWithChildOnlyExistsInScene2()
        {
            var scene2 = TestUtility.defaultScene;

            EditorSceneManager.SaveScene(scene2, TestUtility.tempFilename);

            var scene1 = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);

            EditorSceneManager.SetActiveScene(scene1);

            var model           = TestUtility.CreateUndoableGameObjectWithModel();
            var modelGameObject = model.gameObject;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = model.transform;

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");
            Assert.AreEqual(scene1, model.gameObject.scene);
            Assert.AreEqual(scene1, model.hierarchyItem.Scene);

            Undo.MoveGameObjectToScene(modelGameObject, scene2, "Move gameObject to different scene");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");

            Assert.AreEqual(model.hierarchyItem, brush.hierarchyItem.Parent);
            Assert.AreEqual(model.NodeID, brush.hierarchyItem.Parent.Component.NodeID);
            Assert.AreEqual(model.NodeID, brush.TopNode.Tree.NodeID);

            Assert.AreEqual(scene2, model.gameObject.scene, "Model is not part of expected scene");
            Assert.AreEqual(scene2, model.hierarchyItem.Scene, "Model is not registered to expected scene");

            Assert.AreEqual(scene2, brush.gameObject.scene, "Brush is not part of expected scene");
            Assert.AreEqual(scene2, brush.hierarchyItem.Scene, "Brush is not registered to expected scene");

            Assert.AreEqual(0, CSGNodeHierarchyManager.RootCount(scene1));
            Assert.AreEqual(1, CSGNodeHierarchyManager.RootCount(scene2));

            // make sure test runner doesn't puke on its own bugs
            EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
        }
Esempio n. 2
0
        public IEnumerator Composite1WithChildGameObjectWithChildBrush_MoveChildToComposite2_ChildHasComposite2AsParent()
        {
            var composite1           = TestUtility.CreateUndoableGameObjectWithComposite("composite1");
            var composite1GameObject = composite1.gameObject;

            var composite2           = TestUtility.CreateUndoableGameObjectWithComposite("composite2");
            var composite2GameObject = composite2.gameObject;

            var plainGameObject = TestUtility.CreateGameObject("gameObject");

            plainGameObject.transform.parent = composite1.transform;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = plainGameObject.transform;

            Assert.True(composite1GameObject);
            Assert.True(composite1);
            Assert.True(composite2GameObject);
            Assert.True(composite2);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");

            yield return(null);

            Assert.AreEqual(2, CSGManager.TreeBranchCount, "Expected 2 TreeBranches to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(4, CSGManager.TreeNodeCount, "Expected 4 TreeNodes to Exist");

            Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, composite2.Node.NodeID);
            Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, composite1.Node.NodeID);
            Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, brush.TopNode.NodeID);

            Assert.AreEqual(composite1.Node.NodeID, brush.TopNode.Parent.NodeID);

            Assert.AreEqual(1, composite1.Node.Count);
            Assert.AreEqual(0, composite2.Node.Count);

            brush.transform.parent = composite2.transform;
            yield return(null);

            Assert.AreEqual(composite2.Node.NodeID, brush.TopNode.Parent.NodeID);

            Assert.AreEqual(0, composite1.Node.Count);
            Assert.AreEqual(1, composite2.Node.Count);
        }
Esempio n. 3
0
        public IEnumerator Model1WithChildGameObjectWithChildBrush_MoveChildToModel2_ChildHasModel2AsTree()
        {
            var model1           = TestUtility.CreateUndoableGameObjectWithModel("model1");
            var model1GameObject = model1.gameObject;

            var model2           = TestUtility.CreateUndoableGameObjectWithModel("model2");
            var model2GameObject = model2.gameObject;

            var plainGameObject = TestUtility.CreateGameObject("gameObject");

            plainGameObject.transform.parent = model1.transform;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = plainGameObject.transform;

            Assert.True(model1GameObject);
            Assert.True(model1);
            Assert.True(model2GameObject);
            Assert.True(model2);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");

            yield return(null);

            Assert.AreEqual(2, CSGManager.TreeCount, "Expected 2 Trees to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist");

            Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, model2.Node.NodeID);
            Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, model1.Node.NodeID);
            Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, brush.TopNode.NodeID);

            Assert.AreEqual(model1.Node.NodeID, brush.TopNode.Tree.NodeID);

            Assert.AreEqual(1, model1.Node.Count);
            Assert.AreEqual(0, model2.Node.Count);

            brush.transform.parent = model2.transform;
            yield return(null);

            Assert.AreEqual(model2.Node.NodeID, brush.TopNode.Tree.NodeID);

            Assert.AreEqual(0, model1.Node.Count);
            Assert.AreEqual(1, model2.Node.Count);
        }
        public IEnumerator Operation1WithChildGameObjectWithChildBrush_MoveChildToOperation2_ChildHasOperation2AsParent()
        {
            var operation1           = TestUtility.CreateUndoableGameObjectWithOperation("operation1");
            var operation1GameObject = operation1.gameObject;

            var operation2           = TestUtility.CreateUndoableGameObjectWithOperation("operation2");
            var operation2GameObject = operation2.gameObject;

            var plainGameObject = TestUtility.CreateGameObject("gameObject");

            plainGameObject.transform.parent = operation1.transform;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = plainGameObject.transform;

            Assert.True(operation1GameObject);
            Assert.True(operation1);
            Assert.True(operation2GameObject);
            Assert.True(operation2);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");

            yield return(null);

            Assert.AreEqual(2, CSGManager.TreeBranchCount, "Expected 2 TreeBranches to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(4, CSGManager.TreeNodeCount, "Expected 4 TreeNodes to Exist");

            Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, operation2.Node.NodeID);
            Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, operation1.Node.NodeID);
            Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, brush.TopNode.NodeID);

            Assert.AreEqual(operation1.Node.NodeID, brush.TopNode.Parent.NodeID);

            Assert.AreEqual(1, operation1.Node.Count);
            Assert.AreEqual(0, operation2.Node.Count);

            brush.transform.parent = operation2.transform;
            yield return(null);

            Assert.AreEqual(operation2.Node.NodeID, brush.TopNode.Parent.NodeID);

            Assert.AreEqual(0, operation1.Node.Count);
            Assert.AreEqual(1, operation2.Node.Count);
        }
Esempio n. 5
0
        public IEnumerator Composite1WithWithGameObjectWithBrush_AddComposite2ToGameObject_BrushHasComposite2AsParent()
        {
            var composite1           = TestUtility.CreateUndoableGameObjectWithComposite("composite1");
            var composite1GameObject = composite1.gameObject;

            var composite2GameObject = TestUtility.CreateGameObject("composite2");

            composite2GameObject.transform.parent = composite1GameObject.transform;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush("brush");
            var brushGameObject = brush.gameObject;

            brush.transform.parent = composite2GameObject.transform;

            Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.True(composite1GameObject);
            Assert.True(composite1);
            Assert.True(composite2GameObject);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist");
            Assert.AreEqual(1, composite1.Node.Count);
            Assert.AreEqual(composite1.Node.NodeID, brush.TopNode.Parent.NodeID);

            var composite2 = TestUtility.CreateUndoableCompositeComponent(composite2GameObject);

            yield return(null);

            Assert.True(composite1GameObject);
            Assert.True(composite1);
            Assert.True(composite2GameObject);
            Assert.True(composite2);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(2, CSGManager.TreeBranchCount, "Expected 2 TreeBranches to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(4, CSGManager.TreeNodeCount, "Expected 4 TreeNodes to Exist");
            Assert.AreEqual(1, composite2.Node.Count);
            Assert.AreEqual(1, composite1.Node.Count);
            Assert.AreEqual(composite1.Node.NodeID, composite2.Node.Parent.NodeID);
            Assert.AreEqual(composite2.Node.NodeID, brush.TopNode.Parent.NodeID);
        }
Esempio n. 6
0
        public IEnumerator Composite1WithDisabledComposite2WithChildBrush_EnableComposite2Component_ChildHasComposite2AsParent()
        {
            var composite1           = TestUtility.CreateUndoableGameObjectWithComposite();
            var composite1GameObject = composite1.gameObject;

            var composite2           = TestUtility.CreateUndoableGameObjectWithComposite();
            var composite2GameObject = composite2.gameObject;

            composite2.transform.parent = composite1.transform;
            composite2.enabled          = false;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = composite2.transform;

            Assert.True(composite1GameObject);
            Assert.True(composite1);
            Assert.True(composite2GameObject);
            Assert.True(composite2);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist");

            Assert.AreEqual(1, composite1.Node.Count);

            Assert.AreEqual(composite1.Node.NodeID, brush.TopNode.Parent.NodeID);
            Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, composite2.Node.NodeID);

            composite2.enabled = true;
            yield return(null);

            Assert.AreEqual(2, CSGManager.TreeBranchCount, "Expected 2 TreeBranches to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(4, CSGManager.TreeNodeCount, "Expected 4 TreeNodes to Exist");

            Assert.AreEqual(1, composite1.Node.Count);
            Assert.AreEqual(1, composite2.Node.Count);

            Assert.AreEqual(composite2.Node.NodeID, brush.TopNode.Parent.NodeID);
            Assert.AreEqual(composite1.Node.NodeID, composite2.Node.Parent.NodeID);
        }
        public IEnumerator Operation1WithWithGameObjectWithBrush_AddOperation2ToGameObject_BrushHasOperation2AsParent()
        {
            var operation1           = TestUtility.CreateUndoableGameObjectWithOperation("operation1");
            var operation1GameObject = operation1.gameObject;

            var operation2GameObject = TestUtility.CreateGameObject("operation2");

            operation2GameObject.transform.parent = operation1GameObject.transform;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush("brush");
            var brushGameObject = brush.gameObject;

            brush.transform.parent = operation2GameObject.transform;

            Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.True(operation1GameObject);
            Assert.True(operation1);
            Assert.True(operation2GameObject);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist");
            Assert.AreEqual(1, operation1.Node.Count);
            Assert.AreEqual(operation1.Node.NodeID, brush.TopNode.Parent.NodeID);

            var operation2 = TestUtility.CreateUndoableOperationComponent(operation2GameObject);

            yield return(null);

            Assert.True(operation1GameObject);
            Assert.True(operation1);
            Assert.True(operation2GameObject);
            Assert.True(operation2);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(2, CSGManager.TreeBranchCount, "Expected 2 TreeBranches to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(4, CSGManager.TreeNodeCount, "Expected 4 TreeNodes to Exist");
            Assert.AreEqual(1, operation2.Node.Count);
            Assert.AreEqual(1, operation1.Node.Count);
            Assert.AreEqual(operation1.Node.NodeID, operation2.Node.Parent.NodeID);
            Assert.AreEqual(operation2.Node.NodeID, brush.TopNode.Parent.NodeID);
        }
        public IEnumerator Operation1WithDisabledOperation2WithChildBrush_EnableOperation2Component_ChildHasOperation2AsParent()
        {
            var operation1           = TestUtility.CreateUndoableGameObjectWithOperation();
            var operation1GameObject = operation1.gameObject;

            var operation2           = TestUtility.CreateUndoableGameObjectWithOperation();
            var operation2GameObject = operation2.gameObject;

            operation2.transform.parent = operation1.transform;
            operation2.enabled          = false;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = operation2.transform;

            Assert.True(operation1GameObject);
            Assert.True(operation1);
            Assert.True(operation2GameObject);
            Assert.True(operation2);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist");

            Assert.AreEqual(1, operation1.Node.Count);

            Assert.AreEqual(operation1.Node.NodeID, brush.TopNode.Parent.NodeID);
            Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, operation2.Node.NodeID);

            operation2.enabled = true;
            yield return(null);

            Assert.AreEqual(2, CSGManager.TreeBranchCount, "Expected 2 TreeBranches to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(4, CSGManager.TreeNodeCount, "Expected 4 TreeNodes to Exist");

            Assert.AreEqual(1, operation1.Node.Count);
            Assert.AreEqual(1, operation2.Node.Count);

            Assert.AreEqual(operation2.Node.NodeID, brush.TopNode.Parent.NodeID);
            Assert.AreEqual(operation1.Node.NodeID, operation2.Node.Parent.NodeID);
        }
Esempio n. 9
0
        public IEnumerator Model1WithWithGameObjectWithBrush_AddModel2ToGameObject_BrushHasModel2AsTree()
        {
            var model1           = TestUtility.CreateUndoableGameObjectWithModel("model1");
            var model1GameObject = model1.gameObject;

            var model2GameObject = TestUtility.CreateGameObject("model2");

            model2GameObject.transform.parent = model1GameObject.transform;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush("brush");
            var brushGameObject = brush.gameObject;

            brush.transform.parent = model2GameObject.transform;

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.True(model1GameObject);
            Assert.True(model1);
            Assert.True(model2GameObject);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");
            Assert.AreEqual(1, model1.Node.Count);
            Assert.AreEqual(model1.Node.NodeID, brush.TopNode.Tree.NodeID);

            var model2 = TestUtility.CreateUndoableModelComponent(model2GameObject);

            yield return(null);

            Assert.True(model1GameObject);
            Assert.True(model1);
            Assert.True(model2GameObject);
            Assert.True(model2);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(2, CSGManager.TreeCount, "Expected 2 Trees to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist");
            Assert.AreEqual(0, model1.Node.Count);
            Assert.AreEqual(1, model2.Node.Count);
            Assert.AreEqual(model2.Node.NodeID, brush.TopNode.Tree.NodeID);
        }
        public void CreateBrush_OnlyDirtiesSceneOfBrush()
        {
            var currentScene = SceneManager.GetActiveScene();
            var newScene     = TestUtility.CreateAdditionalSceneAndActivate();

            Assert.False(currentScene.isDirty);
            Assert.False(newScene.isDirty);

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            Assert.AreEqual(brushGameObject.scene, newScene);
            Assert.True(newScene.isDirty);
            Assert.False(currentScene.isDirty);
        }
Esempio n. 11
0
        public IEnumerator Model1WithDeactivatedModel2WithChildBrush_ActivateModel2GameObject_ChildHasModel2AsTree()
        {
            var model1           = TestUtility.CreateUndoableGameObjectWithModel();
            var model1GameObject = model1.gameObject;

            var model2           = TestUtility.CreateUndoableGameObjectWithModel();
            var model2GameObject = model2.gameObject;

            model2.transform.parent = model1.transform;
            model2GameObject.SetActive(false);

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = model2.transform;

            Assert.True(model1GameObject);
            Assert.True(model1);
            Assert.True(model2GameObject);
            Assert.True(model2);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(1, CSGManager.TreeNodeCount, "Expected 1 TreeNode to Exist");

            Assert.AreEqual(0, model1.Node.Count);

            Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, brush.TopNode.NodeID);
            Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, model2.Node.NodeID);

            model2GameObject.SetActive(true);
            yield return(null);

            Assert.AreEqual(2, CSGManager.TreeCount, "Expected 2 Trees to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist");
            Assert.AreEqual(0, model1.Node.Count);
            Assert.AreEqual(1, model2.Node.Count);

            Assert.AreEqual(model2.Node.NodeID, brush.TopNode.Tree.NodeID);
        }
        public IEnumerator Operation1WithOperation2WithChildBrush_DestroyOperationComponent2_ChildHasOperation1AsParent()
        {
            var operation1           = TestUtility.CreateUndoableGameObjectWithOperation();
            var operation1GameObject = operation1.gameObject;

            var operation2           = TestUtility.CreateUndoableGameObjectWithOperation();
            var operation2GameObject = operation2.gameObject;

            operation2.transform.parent = operation1.transform;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = operation2.transform;

            Assert.True(operation1GameObject);
            Assert.True(operation1);
            Assert.True(operation2GameObject);
            Assert.True(operation2);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.AreEqual(2, CSGManager.TreeBranchCount, "Expected 2 TreeBranches to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(4, CSGManager.TreeNodeCount, "Expected 4 TreeNodes to Exist");

            Assert.AreEqual(1, operation1.Node.Count);
            Assert.AreEqual(1, operation2.Node.Count);
            Assert.AreEqual(operation2.Node.NodeID, brush.TopNode.Parent.NodeID);
            Assert.AreEqual(operation1.Node.NodeID, operation2.Node.Parent.NodeID);

            Undo.DestroyObjectImmediate(operation2);
            yield return(null);

            Assert.False(operation2);

            Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist");

            Assert.AreEqual(1, operation1.Node.Count);
            Assert.AreEqual(operation1.Node.NodeID, brush.TopNode.Parent.NodeID);
        }
Esempio n. 13
0
        public IEnumerator Model1WithModel2WithChildBrush_DestroyModel2Component_ChildHasModel1AsTree()
        {
            var model1           = TestUtility.CreateUndoableGameObjectWithModel();
            var model1GameObject = model1.gameObject;

            var model2           = TestUtility.CreateUndoableGameObjectWithModel();
            var model2GameObject = model2.gameObject;

            model2.transform.parent = model1.transform;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = model2.transform;

            Assert.True(model1GameObject);
            Assert.True(model1);
            Assert.True(model2GameObject);
            Assert.True(model2);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.AreEqual(2, CSGManager.TreeCount, "Expected 2 Trees to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist");

            Assert.AreEqual(0, model1.Node.Count);
            Assert.AreEqual(1, model2.Node.Count);
            Assert.AreEqual(model2.Node.NodeID, brush.TopNode.Tree.NodeID);

            Undo.DestroyObjectImmediate(model2);
            yield return(null);

            Assert.False(model2);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");

            Assert.AreEqual(1, model1.Node.Count);
            Assert.AreEqual(model1.Node.NodeID, brush.TopNode.Tree.NodeID);
        }
Esempio n. 14
0
        public IEnumerator ModelWithTwoChildBrushes_SwapOrder_ModelHasChildrenInOrder()
        {
            var model           = TestUtility.CreateUndoableGameObjectWithModel("model");
            var modelGameObject = model.gameObject;

            var brush1           = TestUtility.CreateUndoableGameObjectWithBrush("brush1");
            var brush1GameObject = brush1.gameObject;

            brush1.transform.parent = model.transform;

            var brush2           = TestUtility.CreateUndoableGameObjectWithBrush("brush2");
            var brush2GameObject = brush2.gameObject;

            brush2.transform.parent = model.transform;

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");

            Assert.True(modelGameObject);
            Assert.True(model);
            Assert.True(brush1GameObject);
            Assert.True(brush1);
            Assert.True(brush2GameObject);
            Assert.True(brush2);

            Assert.AreEqual(model.transform.GetChild(0), brush1.transform);
            Assert.AreEqual(model.transform.GetChild(1), brush2.transform);

            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(2, CSGManager.TreeBrushCount, "Expected 2 TreeBrushes to Exist");
            Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist");
            Assert.AreEqual(2, model.Node.Count);
            brush2.transform.SetSiblingIndex(0);

            Assert.AreEqual(model.transform.GetChild(0), brush2.transform);
            Assert.AreEqual(model.transform.GetChild(1), brush1.transform);
            yield return(null);

            Assert.AreEqual(brush2.TopNode.NodeID, model.Node[0].NodeID);
            Assert.AreEqual(brush1.TopNode.NodeID, model.Node[1].NodeID);
        }
Esempio n. 15
0
        public IEnumerator OperationWithTwoChildBrushes_SwapOrder_OperationHasChildrenInOrder()
        {
            var operation           = TestUtility.CreateUndoableGameObjectWithOperation();
            var operationGameObject = operation.gameObject;

            var brush1           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brush1GameObject = brush1.gameObject;

            brush1.transform.parent = operation.transform;

            var brush2           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brush2GameObject = brush2.gameObject;

            brush2.transform.parent = operation.transform;

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");

            Assert.True(operationGameObject);
            Assert.True(operation);
            Assert.True(brush1GameObject);
            Assert.True(brush1);
            Assert.True(brush2GameObject);
            Assert.True(brush2);

            Assert.AreEqual(operation.transform.GetChild(0), brush1.transform);
            Assert.AreEqual(operation.transform.GetChild(1), brush2.transform);

            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist");
            Assert.AreEqual(2, CSGManager.TreeBrushCount, "Expected 2 TreeBrushes to Exist");
            Assert.AreEqual(4, CSGManager.TreeNodeCount, "Expected 4 TreeNodes to Exist");
            Assert.AreEqual(2, operation.Node.Count);
            brush2.transform.SetSiblingIndex(0);

            Assert.AreEqual(operation.transform.GetChild(0), brush2.transform);
            Assert.AreEqual(operation.transform.GetChild(1), brush1.transform);
            yield return(null);

            Assert.AreEqual(brush2.TopNode.NodeID, operation.Node[0].NodeID);
            Assert.AreEqual(brush1.TopNode.NodeID, operation.Node[1].NodeID);
        }
Esempio n. 16
0
        public IEnumerator Model1WithChildBrush_MoveChildOutOfAnyModel_ChildHasNoTreeNodeSet()
        {
            var model1           = TestUtility.CreateUndoableGameObjectWithModel("model1");
            var model1GameObject = model1.gameObject;

            var plainGameObject = TestUtility.CreateGameObject("gameObject");

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = model1.transform;

            Assert.True(model1GameObject);
            Assert.True(model1);
            Assert.True(plainGameObject);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");

            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");

            Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, model1.Node.NodeID);
            Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, brush.TopNode.NodeID);

            Assert.AreEqual(model1.Node.NodeID, brush.TopNode.Tree.NodeID);

            Assert.AreEqual(1, model1.Node.Count);

            brush.transform.parent = plainGameObject.transform;
            yield return(null);

            Assert.AreEqual(0, model1.Node.Count);
            var defaultModel = brush.hierarchyItem.sceneHierarchy.DefaultModel;

            Assert.AreEqual(defaultModel.NodeID, brush.TopNode.Tree.NodeID);
        }
Esempio n. 17
0
        public IEnumerator ModelWithChildBrush_DestroyModel_ChildIsAlsoDestroyed()
        {
            var scene           = TestUtility.defaultScene;
            var model           = TestUtility.CreateUndoableGameObjectWithModel();
            var modelGameObject = model.gameObject;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = model.transform;

            Assert.True(modelGameObject);
            Assert.True(model);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");

            Assert.AreEqual(1, model.Node.Count, 1);
            Assert.AreEqual(model.Node.NodeID, brush.TopNode.Tree.NodeID);

            Undo.DestroyObjectImmediate(modelGameObject);
            yield return(null);

            Assert.False(modelGameObject);
            Assert.False(model);
            Assert.False(brushGameObject);
            Assert.False(brush);

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene));
        }
Esempio n. 18
0
        public IEnumerator OperationWithChildBrush_DestroyOperation_ChildIsDestroyed()
        {
            var scene               = TestUtility.defaultScene;
            var operation           = TestUtility.CreateUndoableGameObjectWithOperation();
            var operationGameObject = operation.gameObject;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = operation.transform;

            Assert.True(operationGameObject);
            Assert.True(operation);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist");

            Assert.AreEqual(1, operation.Node.Count, 1);
            Assert.AreEqual(operation.Node.NodeID, brush.TopNode.Parent.NodeID);

            Undo.DestroyObjectImmediate(operationGameObject);
            yield return(null);

            Assert.False(operationGameObject);
            Assert.False(operation);
            Assert.False(brushGameObject);
            Assert.False(brush);

            Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            Assert.AreEqual(0, CSGNodeHierarchyManager.RootCount(scene));
        }
Esempio n. 19
0
        public IEnumerator ModelWithChildBrush_DisableChildComponent_ModelHasNoChildren()
        {
            var model           = TestUtility.CreateUndoableGameObjectWithModel();
            var modelGameObject = model.gameObject;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = model.transform;

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.True(modelGameObject);
            Assert.True(model);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");
            Assert.AreEqual(1, model.Node.Count);
            Assert.AreEqual(model.Node.NodeID, brush.TopNode.Tree.NodeID);

            brush.enabled = false;
            yield return(null);

            Assert.True(modelGameObject);
            Assert.True(model);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(1, CSGManager.TreeNodeCount, "Expected 1 TreeNode to Exist");
            Assert.AreEqual(0, model.Node.Count);
            yield return(null);
        }
Esempio n. 20
0
        public IEnumerator OperationWithChildBrush_DeactivateChildGameObject_OperationHasNoChildren()
        {
            var operation           = TestUtility.CreateUndoableGameObjectWithOperation();
            var operationGameObject = operation.gameObject;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = operation.transform;

            Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.True(operationGameObject);
            Assert.True(operation);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist");
            Assert.AreEqual(1, operation.Node.Count);
            Assert.AreEqual(operation.Node.NodeID, brush.TopNode.Parent.NodeID);

            brushGameObject.SetActive(false);
            yield return(null);

            Assert.True(operationGameObject);
            Assert.True(operation);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");
            Assert.AreEqual(0, operation.Node.Count);
        }
        public IEnumerator CompositeWithChildBrush_DisableChildComponent_CompositeHasNoChildren()
        {
            var composite           = TestUtility.CreateUndoableGameObjectWithComposite();
            var compositeGameObject = composite.gameObject;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = composite.transform;

            Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.True(compositeGameObject);
            Assert.True(composite);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist");
            Assert.AreEqual(1, composite.Node.Count);
            Assert.AreEqual(composite.Node.NodeID, brush.TopNode.Parent.NodeID);

            brush.enabled = false;
            yield return(null);

            Assert.True(compositeGameObject);
            Assert.True(composite);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");
            Assert.AreEqual(0, composite.Node.Count);
        }
        public IEnumerator CreateBrush_DisableBrushComponent_BrushDoesNotExist()
        {
            var scene           = TestUtility.defaultScene;
            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");

            brush.enabled = false;
            yield return(null);

            Assert.True(brushGameObject);
            Assert.True(brush);
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            Assert.AreEqual(0, CSGNodeHierarchyManager.RootCount(scene));
        }
Esempio n. 23
0
        public IEnumerator CreateBrush_DestroyBrushGameObject_BrushDoesNotExist()
        {
            var scene           = TestUtility.defaultScene;
            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");

            Undo.DestroyObjectImmediate(brushGameObject);
            yield return(null);

            Assert.False(brushGameObject);
            Assert.False(brush);
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene));
        }
Esempio n. 24
0
        public IEnumerator GameObjectWithBrush_AddModelToGameObject_BrushHasModelAsTree()
        {
            var modelGameObject = TestUtility.CreateGameObject("model");

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush("brush");
            var brushGameObject = brush.gameObject;

            brush.transform.parent = modelGameObject.transform;

            Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.True(modelGameObject);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist"); // default model
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");
            Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, brush.TopNode.Parent.NodeID);

            var model = TestUtility.CreateUndoableModelComponent(modelGameObject);

            yield return(null);

            Assert.True(modelGameObject);
            Assert.True(model);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist"); // new model only, default model should've been destroyed
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");
            Assert.AreEqual(1, model.Node.Count);
            Assert.AreEqual(model.Node.NodeID, brush.TopNode.Tree.NodeID);
        }
Esempio n. 25
0
        public IEnumerator Operation1WithOperation2WithChildBrush_DeactivateOperation2GameObject_ChildIsAlsoDeactivated()
        {
            var scene                = TestUtility.defaultScene;
            var operation1           = TestUtility.CreateUndoableGameObjectWithOperation();
            var operation1GameObject = operation1.gameObject;

            var operation2           = TestUtility.CreateUndoableGameObjectWithOperation();
            var operation2GameObject = operation2.gameObject;

            operation2.transform.parent = operation1.transform;
            operation2GameObject.SetActive(false);

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = operation2.transform;

            Assert.True(operation1GameObject);
            Assert.True(operation1);
            Assert.True(operation2GameObject);
            Assert.True(operation2);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");

            Assert.AreEqual(0, operation1.Node.Count);
            Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, brush.TopNode.NodeID);
            Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, operation2.Node.NodeID);
            Assert.AreEqual(1, CSGNodeHierarchyManager.RootCount(scene));
        }
        public IEnumerator GameObjectWithBrush_AddOperationToGameObject_BrushHasOperationAsParent()
        {
            var operationGameObject = TestUtility.CreateGameObject("operation");

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush("brush");
            var brushGameObject = brush.gameObject;

            brush.transform.parent = operationGameObject.transform;

            Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.True(operationGameObject);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");
            Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, brush.TopNode.Parent.NodeID);

            var operation = TestUtility.CreateUndoableOperationComponent(operationGameObject);

            yield return(null);

            Assert.True(operationGameObject);
            Assert.True(operation);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist");
            Assert.AreEqual(1, operation.Node.Count);
            Assert.AreEqual(operation.Node.NodeID, brush.TopNode.Parent.NodeID);
        }
Esempio n. 27
0
        public IEnumerator SaveBrushInScene_LoadScene_BrushTreeNodeIsGenerated()
        {
            var scene1 = TestUtility.defaultScene;
            {
                TestUtility.CreateUndoableGameObjectWithBrush();
                EditorSceneManager.SaveScene(scene1, TestUtility.tempFilename);
            }

            var scene2 = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);

            yield return(null);

            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene2));

            var scene3  = EditorSceneManager.OpenScene(TestUtility.tempFilename);
            var brushes = Object.FindObjectsOfType <ChiselBrush>();

            yield return(null);

            Assert.NotNull(brushes);
            Assert.AreEqual(1, brushes.Length);

            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");
            Assert.AreEqual(1, ChiselNodeHierarchyManager.RootCount(scene3));

            Assert.AreEqual(scene3, brushes[0].gameObject.scene, "Brush is not part of expected scene");
            Assert.AreEqual(scene3, brushes[0].hierarchyItem.Scene, "Brush is not registered to expected scene");

            Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene1)); // unloaded, so should be unknown to us
            Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene2)); // unloaded, so should be unknown to us
            Assert.AreEqual(1, ChiselNodeHierarchyManager.RootCount(scene3));

            // make sure test runner doesn't puke on its own bugs
            EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
        }
Esempio n. 28
0
        public IEnumerator Model1WithModel2WithChildBrush_DeactivateModel2GameObject_ChildIsAlsoDeactivated()
        {
            var scene            = TestUtility.defaultScene;
            var model1           = TestUtility.CreateUndoableGameObjectWithModel();
            var model1GameObject = model1.gameObject;

            var model2           = TestUtility.CreateUndoableGameObjectWithModel();
            var model2GameObject = model2.gameObject;

            model2.transform.parent = model1.transform;
            model2GameObject.SetActive(false);

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = model2.transform;

            Assert.True(model1GameObject);
            Assert.True(model1);
            Assert.True(model2GameObject);
            Assert.True(model2);
            Assert.True(brushGameObject);
            Assert.True(brush);

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(1, CSGManager.TreeNodeCount, "Expected 1 TreeNode to Exist");

            Assert.AreEqual(0, model1.Node.Count);
            Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, brush.TopNode.NodeID);
            Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, model2.Node.NodeID);
            Assert.AreEqual(1, ChiselNodeHierarchyManager.RootCount(scene));
        }
        public IEnumerator Composite_AddTwoChildBrushes_CompositeHasChildrenInOrder()
        {
            var composite           = TestUtility.CreateUndoableGameObjectWithComposite();
            var compositeGameObject = composite.gameObject;

            var brush1           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brush1GameObject = brush1.gameObject;

            brush1.transform.parent = composite.transform;

            var brush2           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brush2GameObject = brush2.gameObject;

            brush2.transform.parent = composite.transform;

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");

            Assert.True(compositeGameObject);
            Assert.True(composite);
            Assert.True(brush1GameObject);
            Assert.True(brush1);
            Assert.True(brush2GameObject);
            Assert.True(brush2);

            Assert.AreEqual(composite.transform.GetChild(0), brush1.transform);
            Assert.AreEqual(composite.transform.GetChild(1), brush2.transform);

            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist");
            Assert.AreEqual(2, CSGManager.TreeBrushCount, "Expected 2 TreeBrushes to Exist");
            Assert.AreEqual(4, CSGManager.TreeNodeCount, "Expected 4 TreeNodes to Exist");
            Assert.AreEqual(2, composite.Node.Count);
            Assert.AreEqual(brush1.TopNode.NodeID, composite.Node[0].NodeID);
            Assert.AreEqual(brush2.TopNode.NodeID, composite.Node[1].NodeID);
        }
        public IEnumerator CreateBrush_DestroyBrushComponent_OnlyDirtiesSceneOfBrush()
        {
            var currentScene = SceneManager.GetActiveScene();
            var newScene     = TestUtility.CreateAdditionalSceneAndActivate();

            Assert.False(currentScene.isDirty);
            Assert.False(newScene.isDirty);

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            Assert.AreEqual(brushGameObject.scene, newScene);
            Assert.True(newScene.isDirty);
            Assert.False(currentScene.isDirty);

            Undo.DestroyObjectImmediate(brush);
            yield return(null);

            Assert.True(brushGameObject);
            Assert.False(brush);
            Assert.True(newScene.isDirty);
            Assert.False(currentScene.isDirty);
        }