Skip to content

Commit c3775d9

Browse files
author
AJubrey
committed
[ADDED] beginning of test
1 parent c7b25f4 commit c3775d9

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

Assets/FbxExporters/Editor/UnitTests/FbxPrefabAutoUpdaterTest.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,56 @@ public void BasicTest ()
5454
imported));
5555
}
5656

57+
[Test]
58+
public void RectTransformTest ()
59+
{
60+
//Create a hierarchy with a RectTransform
61+
var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
62+
var capsule = GameObject.CreatePrimitive(PrimitiveType.Capsule);
63+
capsule.AddComponent<RectTransform>();
64+
65+
capsule.GetComponent<RectTransform>().localScale = new Vector3(1,2,3);
66+
capsule.GetComponent<RectTransform>().localPosition = new Vector3(100,200,300);
67+
68+
capsule.transform.parent = cube.transform;
69+
70+
GameObject originalFBX = ExportSelection(cube);
71+
72+
//instantiate our hierarchy as a prefab
73+
var oldInstance = PrefabUtility.InstantiatePrefab(originalFBX) as GameObject;
74+
Assert.IsTrue(oldInstance);
75+
76+
Debug.Log("ORIGINAL: " + oldInstance.transform.GetChild(0).GetComponent<RectTransform>().localScale);
77+
78+
//Get the file path of our original hierarchy
79+
string filePath = AssetDatabase.GetAssetPath(originalFBX);
80+
81+
//Create an "updated" hierarchy
82+
var cube2 = GameObject.CreatePrimitive(PrimitiveType.Cube);
83+
var capsule2 = GameObject.CreatePrimitive(PrimitiveType.Capsule);
84+
capsule2.AddComponent<RectTransform>();
85+
86+
capsule2.GetComponent<RectTransform>().localScale = new Vector3(3, 2, 1);
87+
capsule2.GetComponent<RectTransform>().localPosition = new Vector3(300, 200, 100);
88+
89+
capsule2.transform.parent = cube2.transform;
90+
91+
GameObject newFBX = ExportSelection(cube2);
92+
93+
//export our updated hierarchy to the same file path as the original
94+
SleepForFileTimestamp();
95+
FbxExporters.Editor.ModelExporter.ExportObject(filePath, cube2);
96+
AssetDatabase.Refresh();
97+
98+
var newInstance = PrefabUtility.InstantiatePrefab(newFBX) as GameObject;
99+
Assert.IsTrue(newInstance);
100+
101+
Debug.Log("NEW BOI: " + newInstance.transform.GetChild(0).GetComponent<RectTransform>().localScale);
102+
103+
AssertSameHierarchy(cube2, oldInstance, ignoreRootName: true, ignoreRootTransform: true);
104+
105+
}
106+
57107
[Test]
58108
public void ReplaceTest ()
59109
{

0 commit comments

Comments
 (0)