1
+ // ***********************************************************************
2
+ // Copyright (c) 2017 Unity Technologies. All rights reserved.
3
+ //
4
+ // Licensed under the ##LICENSENAME##.
5
+ // See LICENSE.md file in the project root for full license information.
6
+ // ***********************************************************************
7
+
8
+ using UnityEngine ;
9
+ using UnityEditor ;
10
+ using UnityEngine . TestTools ;
11
+ using NUnit . Framework ;
12
+ using System . Collections . Generic ;
13
+
14
+ namespace FbxExporters . UnitTests
15
+ {
16
+ public class ModelExporterTest
17
+ {
18
+ // add any GameObject that gets created to this list
19
+ // so that it gets deleted in the TearDown
20
+ private List < GameObject > m_createdObjects ;
21
+
22
+ [ SetUp ]
23
+ public void Init ( )
24
+ {
25
+ m_createdObjects = new List < GameObject > ( ) ;
26
+ }
27
+
28
+ [ TearDown ]
29
+ public void Term ( )
30
+ {
31
+ foreach ( var obj in m_createdObjects ) {
32
+ GameObject . DestroyImmediate ( obj ) ;
33
+ }
34
+ }
35
+
36
+
37
+ [ Test ]
38
+ public void TestFindCenter ( )
39
+ {
40
+ // Create 3 objects
41
+ var cube = GameObject . CreatePrimitive ( PrimitiveType . Cube ) ;
42
+ var cube1 = GameObject . CreatePrimitive ( PrimitiveType . Cube ) ;
43
+ var cube2 = GameObject . CreatePrimitive ( PrimitiveType . Cube ) ;
44
+
45
+ m_createdObjects . Add ( cube ) ;
46
+ m_createdObjects . Add ( cube1 ) ;
47
+ m_createdObjects . Add ( cube2 ) ;
48
+
49
+ // Set their transforms
50
+ cube . transform . localPosition = new Vector3 ( 23 , - 5 , 10 ) ;
51
+ cube1 . transform . localPosition = new Vector3 ( 23 , - 5 , 4 ) ;
52
+ cube1 . transform . localScale = new Vector3 ( 1 , 1 , 2 ) ;
53
+ cube2 . transform . localPosition = new Vector3 ( 28 , 0 , 10 ) ;
54
+ cube2 . transform . localScale = new Vector3 ( 3 , 1 , 1 ) ;
55
+
56
+ // Find the center
57
+ var center = FbxExporters . Editor . ModelExporter . FindCenter ( new GameObject [ ] { cube , cube1 , cube2 } ) ;
58
+
59
+ // Check that it is what we expect
60
+ Assert . AreEqual ( center , new Vector3 ( 26 , - 2.5f , 6.75f ) ) ;
61
+ }
62
+ }
63
+ }
0 commit comments