本文整理汇总了C#中Scene.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.Dispose方法的具体用法?C# Scene.Dispose怎么用?C# Scene.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scene
的用法示例。
在下文中一共展示了Scene.Dispose方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SwitchToDuringUpdate
[Test] public void SwitchToDuringUpdate()
{
// Set up some objects
Scene scene = new Scene();
Scene scene2 = new Scene();
// Switch to the first Scene regularly
{
Scene.SwitchTo(scene);
Assert.AreEqual(Scene.Current, scene);
}
// Switch to the second during update
{
GameObject obj = new GameObject("SwitchObject");
var switchComponent = new UpdateSwitchToSceneComponent { Target = scene2 };
obj.AddComponent(switchComponent);
scene.AddObject(obj);
DualityApp.Update();
Assert.False(switchComponent.Switched);
Assert.AreEqual(Scene.Current, scene2);
Scene.SwitchTo(scene);
Assert.AreEqual(Scene.Current, scene);
}
// Clean up
scene.Dispose();
scene2.Dispose();
}
示例2: SwitchToRegular
[Test] public void SwitchToRegular()
{
// Set up some objects
Scene scene = new Scene();
Scene scene2 = new Scene();
// Switch to the first Scene regularly
{
Scene.SwitchTo(scene);
Assert.AreEqual(Scene.Current, scene);
}
// Clean up
scene.Dispose();
scene2.Dispose();
}
示例3: 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();
}
示例4: GameObjectParentLoop
[Test] public void GameObjectParentLoop()
{
// Set up some objects
Scene scene = new Scene();
GameObject obj = new GameObject("TestObject");
GameObject objChild = new GameObject("TestObjectChild", obj);
GameObject objChildChild = new GameObject("TestObjectChildChild", objChild);
scene.AddObject(obj);
// Attempt to create a closed parent loop. Expect the operation to be rejected.
Assert.Throws<ArgumentException>(() => obj.Parent = objChildChild);
Assert.AreEqual(null, obj.Parent);
Assert.AreEqual(obj, objChild.Parent);
Assert.AreEqual(objChild, objChildChild.Parent);
// Attempt to create a direct self-reference loop. Expect the operation to be rejected.
Assert.Throws<ArgumentException>(() => obj.Parent = obj);
Assert.AreEqual(null, obj.Parent);
Assert.AreEqual(obj, objChild.Parent);
Assert.AreEqual(objChild, objChildChild.Parent);
// Clean up
scene.Dispose();
}
示例5: GameObjectActiveLists
[Test] public void GameObjectActiveLists()
{
// Set up some objects
Scene scene = 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);
scene.AddObject(obj2);
// Inactive objects shouldn't show up in active lists
objChildB.Active = false;
obj2.Active = false;
CollectionAssert.AreEquivalent(new[] { obj, obj2, objChildA, objChildB }, scene.AllObjects);
CollectionAssert.AreEquivalent(new[] { obj, objChildA }, scene.ActiveObjects);
CollectionAssert.AreEquivalent(new[] { obj, obj2 }, scene.RootObjects);
CollectionAssert.AreEquivalent(new[] { obj }, scene.ActiveRootObjects);
// Activating them again should make them show up again
objChildB.Active = true;
obj2.Active = true;
CollectionAssert.AreEquivalent(scene.AllObjects, scene.ActiveObjects);
CollectionAssert.AreEquivalent(scene.RootObjects, scene.ActiveRootObjects);
// Clean up
scene.Dispose();
}
示例6: AddRemoveGameObjectsMultiScene
[Test] 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();
}
示例7: 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();
}