@@ -58,35 +58,43 @@ public void BasicTest ()
58
58
[ Test ]
59
59
public void RectTransformTest ( )
60
60
{
61
- // Get a random directory.
62
- var path = m_fbxPath ;
61
+ Vector3 scaleForward = new Vector3 ( 1 , 2 , 3 ) ;
62
+ Vector3 positionForward = new Vector3 ( 100 , 200 , 300 ) ;
63
+ Vector3 rotationForward = new Vector3 ( 1 , 2 , 3 ) ;
64
+
65
+ Vector3 scaleBackward = new Vector3 ( 3 , 2 , 1 ) ;
66
+ Vector3 positionBackward = new Vector3 ( 300 , 200 , 100 ) ;
67
+ Vector3 rotationBackward = new Vector3 ( 3 , 2 , 1 ) ;
63
68
64
69
//Create a hierarchy with a RectTransform
65
70
var cube = GameObject . CreatePrimitive ( PrimitiveType . Cube ) ;
66
71
var capsule = GameObject . CreatePrimitive ( PrimitiveType . Capsule ) ;
67
72
capsule . AddComponent < RectTransform > ( ) ;
68
73
69
- capsule . GetComponent < RectTransform > ( ) . localScale = new Vector3 ( 1 , 2 , 3 ) ;
70
- capsule . GetComponent < RectTransform > ( ) . localPosition = new Vector3 ( 100 , 200 , 300 ) ;
74
+ capsule . GetComponent < RectTransform > ( ) . localScale = scaleForward ;
75
+ capsule . GetComponent < RectTransform > ( ) . localPosition = positionForward ;
76
+ capsule . GetComponent < RectTransform > ( ) . localRotation = Quaternion . Euler ( rotationForward ) ;
71
77
72
78
capsule . transform . parent = cube . transform ;
73
79
74
- string filePath = Application . dataPath + "/cube.fbx" ;
80
+ string filePath = GetRandomFbxFilePath ( ) ;
75
81
76
82
//instantiate our hierarchy as a prefab
77
83
var oldInstance = ConvertToModel . Convert ( cube , fbxFullPath : filePath ) ;
78
84
Assert . IsTrue ( oldInstance ) ;
79
85
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 ) ) ;
86
+ Assert . IsTrue ( oldInstance . transform . GetChild ( 0 ) . GetComponent < RectTransform > ( ) . localScale == scaleForward ) ;
87
+ Assert . IsTrue ( oldInstance . transform . GetChild ( 0 ) . GetComponent < RectTransform > ( ) . localPosition == positionForward ) ;
88
+ Assert . IsTrue ( oldInstance . transform . GetChild ( 0 ) . GetComponent < RectTransform > ( ) . localRotation == Quaternion . Euler ( rotationForward ) ) ;
82
89
83
90
//Create an "updated" hierarchy
84
91
var cube2 = GameObject . CreatePrimitive ( PrimitiveType . Cube ) ;
85
92
var capsule2 = GameObject . CreatePrimitive ( PrimitiveType . Capsule ) ;
86
93
capsule2 . AddComponent < RectTransform > ( ) ;
87
94
88
- capsule2 . GetComponent < RectTransform > ( ) . localScale = new Vector3 ( 3 , 2 , 1 ) ;
89
- capsule2 . GetComponent < RectTransform > ( ) . localPosition = new Vector3 ( 300 , 200 , 100 ) ;
95
+ capsule2 . GetComponent < RectTransform > ( ) . localScale = scaleBackward ;
96
+ capsule2 . GetComponent < RectTransform > ( ) . localPosition = positionBackward ;
97
+ capsule2 . GetComponent < RectTransform > ( ) . localRotation = Quaternion . Euler ( rotationBackward ) ;
90
98
91
99
capsule2 . transform . parent = cube2 . transform ;
92
100
@@ -95,8 +103,9 @@ public void RectTransformTest ()
95
103
FbxExporters . Editor . ModelExporter . ExportObject ( filePath , cube2 ) ;
96
104
AssetDatabase . Refresh ( ) ;
97
105
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 ) ) ;
106
+ Assert . IsTrue ( oldInstance . transform . GetChild ( 0 ) . GetComponent < RectTransform > ( ) . localScale == scaleBackward ) ;
107
+ Assert . IsTrue ( oldInstance . transform . GetChild ( 0 ) . GetComponent < RectTransform > ( ) . localPosition == positionBackward ) ;
108
+ Assert . IsTrue ( oldInstance . transform . GetChild ( 0 ) . GetComponent < RectTransform > ( ) . localRotation == Quaternion . Euler ( rotationBackward ) ) ;
100
109
101
110
GameObject . DestroyImmediate ( cube ) ;
102
111
GameObject . DestroyImmediate ( cube2 ) ;
0 commit comments