当前位置: 首页>>代码示例>>C#>>正文


C# Scene.RemoveObject方法代码示例

本文整理汇总了C#中Scene.RemoveObject方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.RemoveObject方法的具体用法?C# Scene.RemoveObject怎么用?C# Scene.RemoveObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Scene的用法示例。


在下文中一共展示了Scene.RemoveObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddRemoveGameObjectsMultiScene

        public void AddRemoveGameObjectsMultiScene()
        {
            // Set up some objects
            Scene scene = new Scene();
            Scene scene2 = new Scene();
            GameObject obj = new GameObject("TestObject");
            GameObject obj2 = new GameObject("TestObject2");
            GameObject objChildA = new GameObject("TestObjectChildA", obj);
            GameObject objChildB = new GameObject("TestObjectChildB", obj);
            scene.AddObject(obj);
            scene2.AddObject(obj2);

            // Let object switch Scenes implicitly by parent-child relationship
            objChildA.Parent = obj2;
            Assert.AreEqual(scene2, objChildA.ParentScene);
            CollectionAssert.AreEquivalent(new[] { obj, objChildB }, scene.AllObjects);
            CollectionAssert.AreEquivalent(new[] { obj2, objChildA }, scene2.AllObjects);
            CollectionAssert.Contains(obj2.Children, objChildA);
            Assert.AreEqual(obj2, objChildA.Parent);

            // Remove object from a Scene it doesn't belong to
            scene.RemoveObject(obj2);
            CollectionAssert.AreEquivalent(new[] { obj, objChildB }, scene.AllObjects);
            CollectionAssert.AreEquivalent(new[] { obj2, objChildA }, scene2.AllObjects);

            // Add object to Scene, despite belonging to a different Scene
            scene.AddObject(obj2);
            CollectionAssert.AreEquivalent(new[] { obj, obj2, objChildA, objChildB }, scene.AllObjects);
            CollectionAssert.IsEmpty(scene2.AllObjects);

            // Clean up
            scene.Dispose();
            scene2.Dispose();
        }
开发者ID:BraveSirAndrew,项目名称:duality,代码行数:34,代码来源:SceneTest.cs

示例2: AddRemoveGameObjects

        public void AddRemoveGameObjects()
        {
            // Set up some objects
            Scene scene = new Scene();
            GameObject obj = new GameObject("TestObject");
            GameObject objChildA = new GameObject("TestObjectChildA", obj);
            GameObject objChildB = new GameObject("TestObjectChildB", obj);
            scene.AddObject(obj);

            // Basic setup check (Added properly?)
            Assert.AreEqual(scene, obj.ParentScene);
            CollectionAssert.AreEquivalent(new[] { obj, objChildA, objChildB }, scene.AllObjects);

            // Removing root object
            scene.RemoveObject(obj);
            Assert.AreEqual(null, obj.ParentScene);
            CollectionAssert.IsEmpty(scene.AllObjects);

            // Adding removed root object again
            scene.AddObject(obj);
            Assert.AreEqual(scene, obj.ParentScene);
            CollectionAssert.AreEquivalent(new[] { obj, objChildA, objChildB }, scene.AllObjects);

            // Remove non-root object
            scene.RemoveObject(objChildA);
            CollectionAssert.AreEquivalent(new[] { obj, objChildB }, scene.AllObjects);
            CollectionAssert.DoesNotContain(obj.Children, objChildA);
            Assert.IsNull(objChildA.ParentScene);
            Assert.IsNull(objChildA.Parent);

            // Clear Scene
            scene.Clear();
            CollectionAssert.IsEmpty(scene.AllObjects);

            // Clean up
            scene.Dispose();
        }
开发者ID:BraveSirAndrew,项目名称:duality,代码行数:37,代码来源:SceneTest.cs

示例3: GameObjectHierarchy

		[Test] public void GameObjectHierarchy()
		{
			// Set up some objects
			Scene scene = new Scene();
			Scene scene2 = new Scene();
			GameObject obj = new GameObject("TestObject");
			GameObject obj2 = new GameObject("TestObject2");
			GameObject objChildA = new GameObject("TestObjectChildA", obj);
			GameObject objChildB = new GameObject("TestObjectChildB", obj);
			scene.AddObject(obj);
			scene2.AddObject(obj2);

			// Remove non-root object
			scene.RemoveObject(objChildA);
			CollectionAssert.AreEquivalent(new[] { obj, objChildB }, scene.AllObjects);
			CollectionAssert.DoesNotContain(obj.Children, objChildA);
			Assert.IsNull(objChildA.ParentScene);
			Assert.IsNull(objChildA.Parent);

			// Add object implicitly by parent-child relationship
			objChildA.Parent = obj;
			CollectionAssert.AreEquivalent(new[] { obj, objChildA, objChildB }, scene.AllObjects);
			CollectionAssert.Contains(obj.Children, objChildA);
			Assert.AreEqual(scene, objChildA.ParentScene);
			Assert.AreEqual(obj, objChildA.Parent);

			// Change object parent
			objChildA.Parent = objChildB;
			CollectionAssert.AreEquivalent(new[] { obj, objChildA, objChildB }, scene.AllObjects);
			CollectionAssert.Contains(objChildB.Children, objChildA);
			Assert.AreEqual(scene, objChildA.ParentScene);
			Assert.AreEqual(objChildB, objChildA.Parent);

			// Clean up
			scene.Dispose();
			scene2.Dispose();
		}
开发者ID:arajar,项目名称:duality,代码行数:37,代码来源:SceneTest.cs


注:本文中的Scene.RemoveObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。