3
3
using NUnit . Framework ;
4
4
using System . IO ;
5
5
using System . Collections . Generic ;
6
+ using FbxExporters . Editor ;
6
7
7
8
namespace FbxExporters . UnitTests
8
9
{
@@ -57,6 +58,9 @@ public void BasicTest ()
57
58
[ Test ]
58
59
public void RectTransformTest ( )
59
60
{
61
+ // Get a random directory.
62
+ var path = m_fbxPath ;
63
+
60
64
//Create a hierarchy with a RectTransform
61
65
var cube = GameObject . CreatePrimitive ( PrimitiveType . Cube ) ;
62
66
var capsule = GameObject . CreatePrimitive ( PrimitiveType . Capsule ) ;
@@ -67,16 +71,14 @@ public void RectTransformTest ()
67
71
68
72
capsule . transform . parent = cube . transform ;
69
73
70
- GameObject originalFBX = ExportSelection ( cube ) ;
74
+ string filePath = Application . dataPath + "/ cube.fbx" ;
71
75
72
76
//instantiate our hierarchy as a prefab
73
- var oldInstance = PrefabUtility . InstantiatePrefab ( originalFBX ) as GameObject ;
77
+ var oldInstance = ConvertToModel . Convert ( cube , fbxFullPath : filePath ) ;
74
78
Assert . IsTrue ( oldInstance ) ;
75
79
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
+ Assert . AreEqual ( oldInstance . transform . GetChild ( 0 ) . GetComponent < RectTransform > ( ) . localScale , new Vector3 ( 1 , 2 , 3 ) ) ;
81
+ Assert . AreEqual ( oldInstance . transform . GetChild ( 0 ) . GetComponent < RectTransform > ( ) . localPosition , new Vector3 ( 100 , 200 , 300 ) ) ;
80
82
81
83
//Create an "updated" hierarchy
82
84
var cube2 = GameObject . CreatePrimitive ( PrimitiveType . Cube ) ;
@@ -86,22 +88,18 @@ public void RectTransformTest ()
86
88
capsule2 . GetComponent < RectTransform > ( ) . localScale = new Vector3 ( 3 , 2 , 1 ) ;
87
89
capsule2 . GetComponent < RectTransform > ( ) . localPosition = new Vector3 ( 300 , 200 , 100 ) ;
88
90
89
- capsule2 . transform . parent = cube2 . transform ;
90
-
91
- GameObject newFBX = ExportSelection ( cube2 ) ;
91
+ capsule2 . transform . parent = cube2 . transform ;
92
92
93
93
//export our updated hierarchy to the same file path as the original
94
94
SleepForFileTimestamp ( ) ;
95
95
FbxExporters . Editor . ModelExporter . ExportObject ( filePath , cube2 ) ;
96
96
AssetDatabase . Refresh ( ) ;
97
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 ) ;
98
+ Assert . AreEqual ( oldInstance . transform . GetChild ( 0 ) . GetComponent < RectTransform > ( ) . localScale , new Vector3 ( 3 , 2 , 1 ) ) ;
99
+ Assert . AreEqual ( oldInstance . transform . GetChild ( 0 ) . GetComponent < RectTransform > ( ) . localPosition , new Vector3 ( 300 , 200 , 100 ) ) ;
104
100
101
+ GameObject . DestroyImmediate ( cube ) ;
102
+ GameObject . DestroyImmediate ( cube2 ) ;
105
103
}
106
104
107
105
[ Test ]
0 commit comments