本文整理汇总了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();
}
示例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();
}
示例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();
}