|
@@ -236,6 +236,14 @@ namespace BansheeEditor
|
|
|
// Simple scene save & load
|
|
// Simple scene save & load
|
|
|
{
|
|
{
|
|
|
{
|
|
{
|
|
|
|
|
+ // unitTest4Scene_0.prefab:
|
|
|
|
|
+ // so0 (Comp1)
|
|
|
|
|
+ // - so0_0
|
|
|
|
|
+ // - so0_1 (Comp1)
|
|
|
|
|
+ // - so0_1_0 (Comp1)
|
|
|
|
|
+ // so1 (Comp2)
|
|
|
|
|
+ // - so1_0
|
|
|
|
|
+
|
|
|
SceneObject so0 = new SceneObject("so0");
|
|
SceneObject so0 = new SceneObject("so0");
|
|
|
SceneObject so1 = new SceneObject("so1");
|
|
SceneObject so1 = new SceneObject("so1");
|
|
|
SceneObject so0_0 = new SceneObject("so0_0");
|
|
SceneObject so0_0 = new SceneObject("so0_0");
|
|
@@ -254,27 +262,29 @@ namespace BansheeEditor
|
|
|
|
|
|
|
|
UT1_Component1 comp0 = so0.AddComponent<UT1_Component1>();
|
|
UT1_Component1 comp0 = so0.AddComponent<UT1_Component1>();
|
|
|
UT1_Component2 comp1 = so1.AddComponent<UT1_Component2>();
|
|
UT1_Component2 comp1 = so1.AddComponent<UT1_Component2>();
|
|
|
|
|
+ UT1_Component1 comp1_1 = so0_1.AddComponent<UT1_Component1>();
|
|
|
UT1_Component1 comp0_1_0 = so0_1_0.AddComponent<UT1_Component1>();
|
|
UT1_Component1 comp0_1_0 = so0_1_0.AddComponent<UT1_Component1>();
|
|
|
|
|
|
|
|
comp0.otherSO = so0_1_0;
|
|
comp0.otherSO = so0_1_0;
|
|
|
comp0.otherComponent = comp1;
|
|
comp0.otherComponent = comp1;
|
|
|
|
|
|
|
|
|
|
+ comp1_1.b = "originalValue2";
|
|
|
|
|
+
|
|
|
comp0_1_0.b = "testValue";
|
|
comp0_1_0.b = "testValue";
|
|
|
comp0_1_0.otherSO = so0;
|
|
comp0_1_0.otherSO = so0;
|
|
|
comp0_1_0.otherComponent2 = comp0;
|
|
comp0_1_0.otherComponent2 = comp0;
|
|
|
|
|
|
|
|
- EditorApplication.SaveScene("unitTest4Scene_0");
|
|
|
|
|
|
|
+ EditorApplication.SaveScene("unitTest4Scene_0.prefab");
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- EditorApplication.LoadScene("unitTest4Scene_0");
|
|
|
|
|
|
|
+ EditorApplication.LoadScene("unitTest4Scene_0.prefab");
|
|
|
|
|
|
|
|
SceneObject sceneRoot = Scene.Root;
|
|
SceneObject sceneRoot = Scene.Root;
|
|
|
SceneObject so0 = sceneRoot.FindChild("so0", false);
|
|
SceneObject so0 = sceneRoot.FindChild("so0", false);
|
|
|
SceneObject so1 = sceneRoot.FindChild("so1", false);
|
|
SceneObject so1 = sceneRoot.FindChild("so1", false);
|
|
|
SceneObject so0_0 = so0.FindChild("so0_0", false);
|
|
SceneObject so0_0 = so0.FindChild("so0_0", false);
|
|
|
SceneObject so0_1 = so0.FindChild("so0_1", false);
|
|
SceneObject so0_1 = so0.FindChild("so0_1", false);
|
|
|
- SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
|
|
|
- SceneObject so0_1_0 = so1_0.FindChild("so0_1_0", false);
|
|
|
|
|
|
|
+ SceneObject so0_1_0 = so0_1.FindChild("so0_1_0", false);
|
|
|
|
|
|
|
|
DebugUnit.Assert(so0_0 != null);
|
|
DebugUnit.Assert(so0_0 != null);
|
|
|
DebugUnit.Assert(so0_1 != null);
|
|
DebugUnit.Assert(so0_1 != null);
|
|
@@ -298,6 +308,12 @@ namespace BansheeEditor
|
|
|
// Load & save a scene that contains a prefab and references its objects
|
|
// Load & save a scene that contains a prefab and references its objects
|
|
|
{
|
|
{
|
|
|
{
|
|
{
|
|
|
|
|
+ // unitTest4Scene_1.prefab:
|
|
|
|
|
+ // parentSO0
|
|
|
|
|
+ // - [unitTest4Scene_0.prefab]
|
|
|
|
|
+ // parentSO1
|
|
|
|
|
+ // - parentSO1_0 (Comp1)
|
|
|
|
|
+
|
|
|
Scene.Clear();
|
|
Scene.Clear();
|
|
|
|
|
|
|
|
SceneObject parentSO0 = new SceneObject("parentSO0", false);
|
|
SceneObject parentSO0 = new SceneObject("parentSO0", false);
|
|
@@ -308,23 +324,25 @@ namespace BansheeEditor
|
|
|
|
|
|
|
|
UT1_Component1 parentComp1_0 = parentSO1_0.AddComponent<UT1_Component1>();
|
|
UT1_Component1 parentComp1_0 = parentSO1_0.AddComponent<UT1_Component1>();
|
|
|
|
|
|
|
|
- Prefab scene0Prefab = ProjectLibrary.Load<Prefab>("unitTest4Scene_0");
|
|
|
|
|
|
|
+ Prefab scene0Prefab = ProjectLibrary.Load<Prefab>("unitTest4Scene_0.prefab");
|
|
|
SceneObject prefabInstance = scene0Prefab.Instantiate();
|
|
SceneObject prefabInstance = scene0Prefab.Instantiate();
|
|
|
prefabInstance.Parent = parentSO0;
|
|
prefabInstance.Parent = parentSO0;
|
|
|
|
|
|
|
|
|
|
+ SceneObject so0 = prefabInstance.FindChild("so0", false);
|
|
|
SceneObject so1 = prefabInstance.FindChild("so1", false);
|
|
SceneObject so1 = prefabInstance.FindChild("so1", false);
|
|
|
|
|
+ SceneObject so0_1 = so0.FindChild("so0_1", false);
|
|
|
SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
|
- SceneObject so0_1_0 = so1_0.FindChild("so0_1_0", false);
|
|
|
|
|
|
|
+ SceneObject so0_1_0 = so0_1.FindChild("so0_1_0", false);
|
|
|
|
|
|
|
|
UT1_Component1 comp0_1_0 = so0_1_0.GetComponent<UT1_Component1>();
|
|
UT1_Component1 comp0_1_0 = so0_1_0.GetComponent<UT1_Component1>();
|
|
|
|
|
|
|
|
parentComp1_0.otherSO = so1_0;
|
|
parentComp1_0.otherSO = so1_0;
|
|
|
parentComp1_0.otherComponent2 = comp0_1_0;
|
|
parentComp1_0.otherComponent2 = comp0_1_0;
|
|
|
|
|
|
|
|
- EditorApplication.SaveScene("unitTest4Scene_1");
|
|
|
|
|
|
|
+ EditorApplication.SaveScene("unitTest4Scene_1.prefab");
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- EditorApplication.LoadScene("unitTest4Scene_1");
|
|
|
|
|
|
|
+ EditorApplication.LoadScene("unitTest4Scene_1.prefab");
|
|
|
|
|
|
|
|
SceneObject parentSO0 = Scene.Root.FindChild("parentSO0", false);
|
|
SceneObject parentSO0 = Scene.Root.FindChild("parentSO0", false);
|
|
|
SceneObject parentSO1_0 = parentSO0.FindChild("parentSO1_0", false);
|
|
SceneObject parentSO1_0 = parentSO0.FindChild("parentSO1_0", false);
|
|
@@ -332,9 +350,11 @@ namespace BansheeEditor
|
|
|
UT1_Component1 parentComp1_0 = parentSO1_0.GetComponent<UT1_Component1>();
|
|
UT1_Component1 parentComp1_0 = parentSO1_0.GetComponent<UT1_Component1>();
|
|
|
|
|
|
|
|
SceneObject prefabInstance = parentSO0.GetChild(0);
|
|
SceneObject prefabInstance = parentSO0.GetChild(0);
|
|
|
- SceneObject so1 = prefabInstance.FindChild("so1");
|
|
|
|
|
- SceneObject so1_0 = so1.FindChild("so1_0");
|
|
|
|
|
- SceneObject so0_1_0 = so1_0.FindChild("so0_1_0");
|
|
|
|
|
|
|
+ SceneObject so0 = prefabInstance.FindChild("so0", false);
|
|
|
|
|
+ SceneObject so1 = prefabInstance.FindChild("so1", false);
|
|
|
|
|
+ SceneObject so0_1 = so0.FindChild("so0_1", false);
|
|
|
|
|
+ SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
|
|
|
+ SceneObject so0_1_0 = so0_1.FindChild("so0_1_0", false);
|
|
|
|
|
|
|
|
UT1_Component1 comp0_1_0 = so0_1_0.GetComponent<UT1_Component1>();
|
|
UT1_Component1 comp0_1_0 = so0_1_0.GetComponent<UT1_Component1>();
|
|
|
|
|
|
|
@@ -346,17 +366,26 @@ namespace BansheeEditor
|
|
|
// Modify prefab, reload the scene and ensure it is updated with modified prefab
|
|
// Modify prefab, reload the scene and ensure it is updated with modified prefab
|
|
|
{
|
|
{
|
|
|
{
|
|
{
|
|
|
- Scene.Load("unitTest4Scene_0");
|
|
|
|
|
|
|
+ // unitTest4Scene_0.prefab:
|
|
|
|
|
+ // so0
|
|
|
|
|
+ // - so0_1 (Comp1)
|
|
|
|
|
+ // - so0_1_0 (Comp1)
|
|
|
|
|
+ // so1 (Comp1, Comp2)
|
|
|
|
|
+ // - so1_0
|
|
|
|
|
+ // - so1_1
|
|
|
|
|
+
|
|
|
|
|
+ Scene.Load("unitTest4Scene_0.prefab");
|
|
|
|
|
|
|
|
SceneObject sceneRoot = Scene.Root;
|
|
SceneObject sceneRoot = Scene.Root;
|
|
|
SceneObject so0 = sceneRoot.FindChild("so0", false);
|
|
SceneObject so0 = sceneRoot.FindChild("so0", false);
|
|
|
SceneObject so0_0 = so0.FindChild("so0_0", false);
|
|
SceneObject so0_0 = so0.FindChild("so0_0", false);
|
|
|
|
|
+ SceneObject so0_1 = so0.FindChild("so0_1", false);
|
|
|
SceneObject so1 = sceneRoot.FindChild("so1", false);
|
|
SceneObject so1 = sceneRoot.FindChild("so1", false);
|
|
|
SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
|
- SceneObject so0_1_0 = so1_0.FindChild("so0_1_0", false);
|
|
|
|
|
|
|
+ SceneObject so0_1_0 = so0_1.FindChild("so0_1_0", false);
|
|
|
|
|
|
|
|
SceneObject so1_1 = new SceneObject("so1_1");
|
|
SceneObject so1_1 = new SceneObject("so1_1");
|
|
|
- so1_1.Parent = so1_0;
|
|
|
|
|
|
|
+ so1_1.Parent = so1;
|
|
|
|
|
|
|
|
so0.RemoveComponent<UT1_Component1>();
|
|
so0.RemoveComponent<UT1_Component1>();
|
|
|
UT1_Component1 comp1 = so1.AddComponent<UT1_Component1>();
|
|
UT1_Component1 comp1 = so1.AddComponent<UT1_Component1>();
|
|
@@ -375,11 +404,11 @@ namespace BansheeEditor
|
|
|
so1.Name = "so1_modified";
|
|
so1.Name = "so1_modified";
|
|
|
so1.Position = new Vector3(0, 999.0f, 0.0f);
|
|
so1.Position = new Vector3(0, 999.0f, 0.0f);
|
|
|
|
|
|
|
|
- EditorApplication.SaveScene("unitTest4Scene_0");
|
|
|
|
|
|
|
+ EditorApplication.SaveScene("unitTest4Scene_0.prefab");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- EditorApplication.LoadScene("unitTest4Scene_1");
|
|
|
|
|
|
|
+ EditorApplication.LoadScene("unitTest4Scene_1.prefab");
|
|
|
|
|
|
|
|
SceneObject parentSO0 = Scene.Root.FindChild("parentSO0", false);
|
|
SceneObject parentSO0 = Scene.Root.FindChild("parentSO0", false);
|
|
|
SceneObject parentSO1_0 = parentSO0.FindChild("parentSO1_0", false);
|
|
SceneObject parentSO1_0 = parentSO0.FindChild("parentSO1_0", false);
|
|
@@ -390,9 +419,10 @@ namespace BansheeEditor
|
|
|
SceneObject so0 = prefabInstance.FindChild("so0", false);
|
|
SceneObject so0 = prefabInstance.FindChild("so0", false);
|
|
|
SceneObject so1 = prefabInstance.FindChild("so1_modified", false);
|
|
SceneObject so1 = prefabInstance.FindChild("so1_modified", false);
|
|
|
SceneObject so0_0 = so0.FindChild("so0_0", false);
|
|
SceneObject so0_0 = so0.FindChild("so0_0", false);
|
|
|
|
|
+ SceneObject so0_1 = so0.FindChild("so0_1", false);
|
|
|
SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
|
- SceneObject so0_1_0 = so1_0.FindChild("so0_1_0", false);
|
|
|
|
|
- SceneObject so1_1 = so1_0.FindChild("so1_1", false);
|
|
|
|
|
|
|
+ SceneObject so0_1_0 = so0_1.FindChild("so0_1_0", false);
|
|
|
|
|
+ SceneObject so1_1 = so1.FindChild("so1_1", false);
|
|
|
|
|
|
|
|
UT1_Component1 comp0 = so0.GetComponent<UT1_Component1>();
|
|
UT1_Component1 comp0 = so0.GetComponent<UT1_Component1>();
|
|
|
UT1_Component1 comp1 = so1.GetComponent<UT1_Component1>();
|
|
UT1_Component1 comp1 = so1.GetComponent<UT1_Component1>();
|
|
@@ -418,6 +448,20 @@ namespace BansheeEditor
|
|
|
{
|
|
{
|
|
|
// Create new scene referencing the prefab and make instance modifications
|
|
// Create new scene referencing the prefab and make instance modifications
|
|
|
{
|
|
{
|
|
|
|
|
+ // unitTest4Scene_2.prefab:
|
|
|
|
|
+ // parent2SO0
|
|
|
|
|
+ // - [unitTest4Scene_0.prefab]
|
|
|
|
|
+ // parent2SO1
|
|
|
|
|
+ // - parent2SO1_0 (Comp1)
|
|
|
|
|
+
|
|
|
|
|
+ // unitTest4Scene_0.prefab (unitTest4Scene_2.prefab instance):
|
|
|
|
|
+ // so0 (Comp1(INSTANCE))
|
|
|
|
|
+ // - so0_0 (INSTANCE)
|
|
|
|
|
+ // - so0_1 (Comp1)
|
|
|
|
|
+ // - so0_1_0 (Comp1)
|
|
|
|
|
+ // so1 (Comp2)
|
|
|
|
|
+ // - so1_0
|
|
|
|
|
+
|
|
|
Scene.Clear();
|
|
Scene.Clear();
|
|
|
|
|
|
|
|
SceneObject parent2SO0 = new SceneObject("parent2SO0");
|
|
SceneObject parent2SO0 = new SceneObject("parent2SO0");
|
|
@@ -428,19 +472,21 @@ namespace BansheeEditor
|
|
|
|
|
|
|
|
UT1_Component1 parentComp1_0 = parent2SO1_0.AddComponent<UT1_Component1>();
|
|
UT1_Component1 parentComp1_0 = parent2SO1_0.AddComponent<UT1_Component1>();
|
|
|
|
|
|
|
|
- Prefab scene0Prefab = ProjectLibrary.Load<Prefab>("unitTest4Scene_0");
|
|
|
|
|
|
|
+ Prefab scene0Prefab = ProjectLibrary.Load<Prefab>("unitTest4Scene_0.prefab");
|
|
|
SceneObject prefabInstance = scene0Prefab.Instantiate();
|
|
SceneObject prefabInstance = scene0Prefab.Instantiate();
|
|
|
prefabInstance.Parent = parent2SO0;
|
|
prefabInstance.Parent = parent2SO0;
|
|
|
|
|
|
|
|
SceneObject so0 = prefabInstance.FindChild("so0", false);
|
|
SceneObject so0 = prefabInstance.FindChild("so0", false);
|
|
|
SceneObject so1 = prefabInstance.FindChild("so1", false);
|
|
SceneObject so1 = prefabInstance.FindChild("so1", false);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ SceneObject so0_1 = so1.FindChild("so0_1", false);
|
|
|
SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
|
- SceneObject so1_1 = so1_0.FindChild("so1_1", false);
|
|
|
|
|
- SceneObject so0_1_0 = so1_0.FindChild("so0_1_0", false);
|
|
|
|
|
|
|
+ SceneObject so1_1 = so1.FindChild("so1_1", false);
|
|
|
|
|
+ SceneObject so0_1_0 = so0_1.FindChild("so0_1_0", false);
|
|
|
|
|
|
|
|
UT1_Component2 comp1 = so1.GetComponent<UT1_Component2>();
|
|
UT1_Component2 comp1 = so1.GetComponent<UT1_Component2>();
|
|
|
UT1_Component1 comp0_1_0 = so0_1_0.GetComponent<UT1_Component1>();
|
|
UT1_Component1 comp0_1_0 = so0_1_0.GetComponent<UT1_Component1>();
|
|
|
|
|
+ UT1_Component1 comp0_1 = so0_1.GetComponent<UT1_Component1>();
|
|
|
|
|
|
|
|
SceneObject so0_0 = new SceneObject("so0_0");
|
|
SceneObject so0_0 = new SceneObject("so0_0");
|
|
|
so0_0.Parent = so0;
|
|
so0_0.Parent = so0;
|
|
@@ -459,12 +505,14 @@ namespace BansheeEditor
|
|
|
comp0_1_0.otherComponent2 = parentComp1_0;
|
|
comp0_1_0.otherComponent2 = parentComp1_0;
|
|
|
comp0_1_0.b = "instanceValue";
|
|
comp0_1_0.b = "instanceValue";
|
|
|
|
|
|
|
|
- EditorApplication.SaveScene("unitTest4Scene_2");
|
|
|
|
|
|
|
+ comp0_1.b = "instanceValue2";
|
|
|
|
|
+
|
|
|
|
|
+ EditorApplication.SaveScene("unitTest4Scene_2.prefab");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Reload the scene and ensure instance modifications remain
|
|
// Reload the scene and ensure instance modifications remain
|
|
|
{
|
|
{
|
|
|
- EditorApplication.LoadScene("unitTest4Scene_2");
|
|
|
|
|
|
|
+ EditorApplication.LoadScene("unitTest4Scene_2.prefab");
|
|
|
|
|
|
|
|
SceneObject root = Scene.Root;
|
|
SceneObject root = Scene.Root;
|
|
|
SceneObject parent2SO0 = root.FindChild("parent2SO0", false);
|
|
SceneObject parent2SO0 = root.FindChild("parent2SO0", false);
|
|
@@ -475,15 +523,17 @@ namespace BansheeEditor
|
|
|
SceneObject so0 = prefabInstance.FindChild("so0", false);
|
|
SceneObject so0 = prefabInstance.FindChild("so0", false);
|
|
|
SceneObject so1 = prefabInstance.FindChild("so1", false);
|
|
SceneObject so1 = prefabInstance.FindChild("so1", false);
|
|
|
SceneObject so0_0 = so0.FindChild("so0_0", false);
|
|
SceneObject so0_0 = so0.FindChild("so0_0", false);
|
|
|
|
|
+ SceneObject so0_1 = so0.FindChild("so0_1", false);
|
|
|
SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
|
- SceneObject so1_1 = so1_0.FindChild("so1_1", false);
|
|
|
|
|
- SceneObject so0_1_0 = so1_0.FindChild("so0_1_0", false);
|
|
|
|
|
|
|
+ SceneObject so1_1 = so1.FindChild("so1_1", false);
|
|
|
|
|
+ SceneObject so0_1_0 = so0_1.FindChild("so0_1_0", false);
|
|
|
|
|
|
|
|
UT1_Component1 parentComp1_0 = parent2SO1_0.GetComponent<UT1_Component1>();
|
|
UT1_Component1 parentComp1_0 = parent2SO1_0.GetComponent<UT1_Component1>();
|
|
|
UT1_Component1 comp0 = so0.GetComponent<UT1_Component1>();
|
|
UT1_Component1 comp0 = so0.GetComponent<UT1_Component1>();
|
|
|
UT1_Component2 comp1 = so1.GetComponent<UT1_Component2>();
|
|
UT1_Component2 comp1 = so1.GetComponent<UT1_Component2>();
|
|
|
UT1_Component1 comp11 = so1.GetComponent<UT1_Component1>();
|
|
UT1_Component1 comp11 = so1.GetComponent<UT1_Component1>();
|
|
|
UT1_Component1 comp0_1_0 = so0_1_0.GetComponent<UT1_Component1>();
|
|
UT1_Component1 comp0_1_0 = so0_1_0.GetComponent<UT1_Component1>();
|
|
|
|
|
+ UT1_Component1 comp0_1 = so0_1.GetComponent<UT1_Component1>();
|
|
|
|
|
|
|
|
DebugUnit.Assert(so0_0 != null);
|
|
DebugUnit.Assert(so0_0 != null);
|
|
|
DebugUnit.Assert(comp0 != null);
|
|
DebugUnit.Assert(comp0 != null);
|
|
@@ -499,11 +549,13 @@ namespace BansheeEditor
|
|
|
DebugUnit.Assert(comp0_1_0.otherSO == parent2SO1_0);
|
|
DebugUnit.Assert(comp0_1_0.otherSO == parent2SO1_0);
|
|
|
DebugUnit.Assert(comp0_1_0.otherComponent2 == parentComp1_0);
|
|
DebugUnit.Assert(comp0_1_0.otherComponent2 == parentComp1_0);
|
|
|
DebugUnit.Assert(comp0_1_0.b == "instanceValue");
|
|
DebugUnit.Assert(comp0_1_0.b == "instanceValue");
|
|
|
|
|
+
|
|
|
|
|
+ DebugUnit.Assert(comp0_1.b == "instanceValue2");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Load original scene and ensure instance modifications didn't influence it
|
|
// Load original scene and ensure instance modifications didn't influence it
|
|
|
{
|
|
{
|
|
|
- EditorApplication.LoadScene("unitTest4Scene_1");
|
|
|
|
|
|
|
+ EditorApplication.LoadScene("unitTest4Scene_1.prefab");
|
|
|
|
|
|
|
|
SceneObject parentSO0 = Scene.Root.FindChild("parentSO0", false);
|
|
SceneObject parentSO0 = Scene.Root.FindChild("parentSO0", false);
|
|
|
SceneObject parentSO1_0 = parentSO0.FindChild("parentSO1_0", false);
|
|
SceneObject parentSO1_0 = parentSO0.FindChild("parentSO1_0", false);
|
|
@@ -514,13 +566,15 @@ namespace BansheeEditor
|
|
|
SceneObject so0 = prefabInstance.FindChild("so0", false);
|
|
SceneObject so0 = prefabInstance.FindChild("so0", false);
|
|
|
SceneObject so1 = prefabInstance.FindChild("so1_modified", false);
|
|
SceneObject so1 = prefabInstance.FindChild("so1_modified", false);
|
|
|
SceneObject so0_0 = so0.FindChild("so0_0", false);
|
|
SceneObject so0_0 = so0.FindChild("so0_0", false);
|
|
|
|
|
+ SceneObject so0_1 = so0.FindChild("so0_1", false);
|
|
|
SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
|
- SceneObject so0_1_0 = so1_0.FindChild("so0_1_0", false);
|
|
|
|
|
- SceneObject so1_1 = so1_0.FindChild("so1_1", false);
|
|
|
|
|
|
|
+ SceneObject so0_1_0 = so0_1.FindChild("so0_1_0", false);
|
|
|
|
|
+ SceneObject so1_1 = so1.FindChild("so1_1", false);
|
|
|
|
|
|
|
|
UT1_Component1 comp0 = so0.GetComponent<UT1_Component1>();
|
|
UT1_Component1 comp0 = so0.GetComponent<UT1_Component1>();
|
|
|
UT1_Component1 comp1 = so1.GetComponent<UT1_Component1>();
|
|
UT1_Component1 comp1 = so1.GetComponent<UT1_Component1>();
|
|
|
UT1_Component1 comp0_1_0 = so0_1_0.GetComponent<UT1_Component1>();
|
|
UT1_Component1 comp0_1_0 = so0_1_0.GetComponent<UT1_Component1>();
|
|
|
|
|
+ UT1_Component1 comp0_1 = so0_1.GetComponent<UT1_Component1>();
|
|
|
|
|
|
|
|
DebugUnit.Assert(parentComp1_0.otherSO == so1_0);
|
|
DebugUnit.Assert(parentComp1_0.otherSO == so1_0);
|
|
|
DebugUnit.Assert(parentComp1_0.otherComponent2 == comp0_1_0);
|
|
DebugUnit.Assert(parentComp1_0.otherComponent2 == comp0_1_0);
|
|
@@ -533,36 +587,104 @@ namespace BansheeEditor
|
|
|
DebugUnit.Assert(comp0_1_0.b == "modifiedValue");
|
|
DebugUnit.Assert(comp0_1_0.b == "modifiedValue");
|
|
|
DebugUnit.Assert(comp1.otherSO == so1_0);
|
|
DebugUnit.Assert(comp1.otherSO == so1_0);
|
|
|
DebugUnit.Assert(comp1.otherComponent2 == comp0_1_0);
|
|
DebugUnit.Assert(comp1.otherComponent2 == comp0_1_0);
|
|
|
|
|
+ DebugUnit.Assert(comp0_1.b == "originalValue2");
|
|
|
DebugUnit.Assert(MathEx.ApproxEquals(so1.Position.y, 999.0f));
|
|
DebugUnit.Assert(MathEx.ApproxEquals(so1.Position.y, 999.0f));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Modify prefab and ensure both prefab and instance modifications remain
|
|
// Modify prefab and ensure both prefab and instance modifications remain
|
|
|
{
|
|
{
|
|
|
- Scene.Load("unitTest4Scene_0");
|
|
|
|
|
|
|
+ // unitTest4Scene_0.prefab:
|
|
|
|
|
+ // so0 (Comp1)
|
|
|
|
|
+ // - so0_1
|
|
|
|
|
+ // - so0_1_0 (Comp1)
|
|
|
|
|
+ // so1 (Comp1, Comp2)
|
|
|
|
|
+ // - so1_1
|
|
|
|
|
+ // - so1_2 (Comp1)
|
|
|
|
|
+
|
|
|
|
|
+ // unitTest4Scene_0.prefab (unitTest4Scene_2.prefab instance):
|
|
|
|
|
+ // so0 (Comp1)
|
|
|
|
|
+ // - so0_0
|
|
|
|
|
+ // - so0_1 (Comp1)
|
|
|
|
|
+ // - so0_1_0 (Comp1)
|
|
|
|
|
+ // so1 (Comp2)
|
|
|
|
|
+ // - so1_2 (Comp1)
|
|
|
|
|
+
|
|
|
|
|
+ Scene.Load("unitTest4Scene_0.prefab");
|
|
|
|
|
|
|
|
SceneObject sceneRoot = Scene.Root;
|
|
SceneObject sceneRoot = Scene.Root;
|
|
|
SceneObject so0 = sceneRoot.FindChild("so0", false);
|
|
SceneObject so0 = sceneRoot.FindChild("so0", false);
|
|
|
|
|
+ SceneObject so0_1 = so0.FindChild("so0_1", false);
|
|
|
SceneObject so1 = sceneRoot.FindChild("so1_modified", false);
|
|
SceneObject so1 = sceneRoot.FindChild("so1_modified", false);
|
|
|
SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
|
- SceneObject so0_1_0 = so1_0.FindChild("so0_1_0", false);
|
|
|
|
|
|
|
+ SceneObject so0_1_0 = so0_1.FindChild("so0_1_0", false);
|
|
|
|
|
|
|
|
SceneObject so1_2 = new SceneObject("so1_2");
|
|
SceneObject so1_2 = new SceneObject("so1_2");
|
|
|
so1_2.Parent = so1;
|
|
so1_2.Parent = so1;
|
|
|
|
|
|
|
|
- UT1_Component2 comp3 = so1_2.AddComponent<UT1_Component2>();
|
|
|
|
|
|
|
+ so0.AddComponent<UT1_Component1>();
|
|
|
|
|
+ so0_1.RemoveComponent<UT1_Component1>();
|
|
|
|
|
+ so1_0.Destroy();
|
|
|
|
|
|
|
|
|
|
+ UT1_Component1 comp3 = so1_2.AddComponent<UT1_Component1>();
|
|
|
UT1_Component1 comp0_1_0 = so0_1_0.GetComponent<UT1_Component1>();
|
|
UT1_Component1 comp0_1_0 = so0_1_0.GetComponent<UT1_Component1>();
|
|
|
comp0_1_0.b = "modifiedValueAgain";
|
|
comp0_1_0.b = "modifiedValueAgain";
|
|
|
so1.Name = "so1_modifiedAgain";
|
|
so1.Name = "so1_modifiedAgain";
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ comp3.otherSO = so0_1;
|
|
|
|
|
+ comp3.otherComponent2 = comp0_1_0;
|
|
|
|
|
+
|
|
|
|
|
+ EditorApplication.SaveScene("unitTest4Scene_0.prefab");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // TODO - Hook up references for comp3
|
|
|
|
|
- // TODO - Remove a component/so from the prefab
|
|
|
|
|
|
|
+ // Reload the scene and ensure both instance and prefab modifications remain
|
|
|
|
|
+ {
|
|
|
|
|
+ EditorApplication.LoadScene("unitTest4Scene_2.prefab");
|
|
|
|
|
|
|
|
- EditorApplication.SaveScene("unitTest4Scene_0");
|
|
|
|
|
|
|
+ SceneObject root = Scene.Root;
|
|
|
|
|
+ SceneObject parent2SO0 = root.FindChild("parent2SO0", false);
|
|
|
|
|
+ SceneObject parent2SO1_0 = root.FindChild("parent2SO1_0", false);
|
|
|
|
|
+
|
|
|
|
|
+ SceneObject prefabInstance = parent2SO0.GetChild(0);
|
|
|
|
|
+
|
|
|
|
|
+ SceneObject so0 = prefabInstance.FindChild("so0", false);
|
|
|
|
|
+ SceneObject so1 = prefabInstance.FindChild("so1", false);
|
|
|
|
|
+ SceneObject so0_0 = so0.FindChild("so0_0", false);
|
|
|
|
|
+ SceneObject so0_1 = so0.FindChild("so0_1", false);
|
|
|
|
|
+ SceneObject so1_0 = so1.FindChild("so1_0", false);
|
|
|
|
|
+ SceneObject so1_1 = so1.FindChild("so1_1", false);
|
|
|
|
|
+ SceneObject so1_2 = so1.FindChild("so1_2", false);
|
|
|
|
|
+ SceneObject so0_1_0 = so0_1.FindChild("so0_1_0", false);
|
|
|
|
|
+
|
|
|
|
|
+ UT1_Component1 parentComp1_0 = parent2SO1_0.GetComponent<UT1_Component1>();
|
|
|
|
|
+ UT1_Component1 comp0 = so0.GetComponent<UT1_Component1>();
|
|
|
|
|
+ UT1_Component2 comp1 = so1.GetComponent<UT1_Component2>();
|
|
|
|
|
+ UT1_Component1 comp11 = so1.GetComponent<UT1_Component1>();
|
|
|
|
|
+ UT1_Component1 comp0_1 = so1_1.GetComponent<UT1_Component1>();
|
|
|
|
|
+ UT1_Component1 comp0_1_0 = so0_1_0.GetComponent<UT1_Component1>();
|
|
|
|
|
+ UT1_Component1 comp3 = so1_2.AddComponent<UT1_Component1>();
|
|
|
|
|
+
|
|
|
|
|
+ // Check instance modifications (they should override any prefab modifications)
|
|
|
|
|
+ DebugUnit.Assert(so0_0 != null);
|
|
|
|
|
+ DebugUnit.Assert(comp0 != null);
|
|
|
|
|
+ DebugUnit.Assert(so1_1 == null);
|
|
|
|
|
+ DebugUnit.Assert(comp11 == null);
|
|
|
|
|
+
|
|
|
|
|
+ DebugUnit.Assert(comp0.otherSO == so0_1_0);
|
|
|
|
|
+ DebugUnit.Assert(comp0.otherComponent == comp1);
|
|
|
|
|
+
|
|
|
|
|
+ DebugUnit.Assert(parentComp1_0.otherSO == so1_0);
|
|
|
|
|
+ DebugUnit.Assert(parentComp1_0.otherComponent2 == comp0_1_0);
|
|
|
|
|
+
|
|
|
|
|
+ DebugUnit.Assert(comp0_1_0.otherSO == parent2SO1_0);
|
|
|
|
|
+ DebugUnit.Assert(comp0_1_0.otherComponent2 == parentComp1_0);
|
|
|
|
|
+ DebugUnit.Assert(comp0_1_0.b == "instanceValue");
|
|
|
|
|
|
|
|
- // TODO - Actually test values
|
|
|
|
|
|
|
+ // Check prefab modifications
|
|
|
|
|
+ DebugUnit.Assert(comp0_1 != null);
|
|
|
|
|
+ DebugUnit.Assert(so1_0 == null);
|
|
|
|
|
+ DebugUnit.Assert(so1.Name == "so1_modifiedAgain");
|
|
|
|
|
+ DebugUnit.Assert(comp3.otherSO == so0_1);
|
|
|
|
|
+ DebugUnit.Assert(comp3.otherComponent2 == comp0_1_0);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -572,9 +694,9 @@ namespace BansheeEditor
|
|
|
Scene.Clear();
|
|
Scene.Clear();
|
|
|
|
|
|
|
|
// TODO - This cleanup should happen regardless if unit test fails or succeeds
|
|
// TODO - This cleanup should happen regardless if unit test fails or succeeds
|
|
|
- ProjectLibrary.Delete("unitTest4Scene_0");
|
|
|
|
|
- ProjectLibrary.Delete("unitTest4Scene_1");
|
|
|
|
|
- ProjectLibrary.Delete("unitTest4Scene_2");
|
|
|
|
|
|
|
+ ProjectLibrary.Delete("unitTest4Scene_0.prefab");
|
|
|
|
|
+ ProjectLibrary.Delete("unitTest4Scene_1.prefab");
|
|
|
|
|
+ ProjectLibrary.Delete("unitTest4Scene_2.prefab");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|