@@ -7,26 +7,27 @@ namespace FbxExporters.UnitTests
7
7
public class FbxLightTest : ExporterTestBase
8
8
{
9
9
[ Test ]
10
- public void AnimationWithLightTest ( )
10
+ public void AnimationWithLightSpotAngleTest ( )
11
11
{
12
12
string filename = GetRandomFbxFilePath ( ) ;
13
13
GameObject go = new GameObject ( ) ;
14
14
go . name = "original" ;
15
15
Light light = go . AddComponent ( typeof ( Light ) ) as Light ;
16
+ light . type = LightType . Spot ;
16
17
Animation anim = go . AddComponent ( typeof ( Animation ) ) as Animation ;
17
18
18
19
Keyframe [ ] keys = new Keyframe [ 3 ] ;
19
- keys [ 0 ] = new Keyframe ( 0.0f , 0.25f ) ;
20
- keys [ 1 ] = new Keyframe ( 1.0f , 0.5f ) ;
21
- keys [ 2 ] = new Keyframe ( 2.0f , 1.0f ) ;
20
+ keys [ 0 ] = new Keyframe ( 0.0f , 1f ) ;
21
+ keys [ 1 ] = new Keyframe ( 1.0f , 2f ) ;
22
+ keys [ 2 ] = new Keyframe ( 2.0f , 3f ) ;
22
23
23
24
AnimationCurve curve = new AnimationCurve ( keys ) ;
24
25
25
26
AnimationClip clip = new AnimationClip ( ) ;
26
27
27
28
clip . legacy = true ;
28
29
29
- clip . SetCurve ( "" , typeof ( Light ) , "m_Intensity " , curve ) ;
30
+ clip . SetCurve ( "" , typeof ( Light ) , "m_SpotAngle " , curve ) ;
30
31
31
32
anim . AddClip ( clip , "test" ) ;
32
33
@@ -55,9 +56,74 @@ public void AnimationWithLightTest()
55
56
if ( exportedClip != null ) break ;
56
57
}
57
58
59
+ Assert . IsNotNull ( exportedClip ) ;
58
60
exportedClip . legacy = true ;
61
+
62
+ EditorCurveBinding exportedEditorCurveBinding = AnimationUtility . GetCurveBindings ( exportedClip ) [ 0 ] ;
63
+
64
+ AnimationCurve exportedCurve = AnimationUtility . GetEditorCurve ( exportedClip , exportedEditorCurveBinding ) ;
65
+
66
+ Assert . That ( exportedCurve . keys . Length , Is . EqualTo ( keys . Length ) ) ;
67
+
68
+ for ( int i = 0 ; i < exportedCurve . keys . Length ; i ++ )
69
+ {
70
+ Assert . That ( exportedCurve . keys [ i ] . time == keys [ i ] . time ) ;
71
+ Assert . That ( exportedCurve . keys [ i ] . value == keys [ i ] . value ) ;
72
+ }
73
+ }
74
+
75
+ [ Test ]
76
+ public void AnimationWithLightIntensityTest ( )
77
+ {
78
+ string filename = GetRandomFbxFilePath ( ) ;
79
+ GameObject go = new GameObject ( ) ;
80
+ go . name = "original" ;
81
+ Light light = go . AddComponent ( typeof ( Light ) ) as Light ;
82
+ Animation anim = go . AddComponent ( typeof ( Animation ) ) as Animation ;
83
+
84
+ Keyframe [ ] keys = new Keyframe [ 3 ] ;
85
+ keys [ 0 ] = new Keyframe ( 0.0f , 1f ) ;
86
+ keys [ 1 ] = new Keyframe ( 1.0f , 2f ) ;
87
+ keys [ 2 ] = new Keyframe ( 2.0f , 3f ) ;
88
+
89
+ AnimationCurve curve = new AnimationCurve ( keys ) ;
90
+
91
+ AnimationClip clip = new AnimationClip ( ) ;
92
+
93
+ clip . legacy = true ;
94
+
95
+ clip . SetCurve ( "" , typeof ( Light ) , "m_Intensity" , curve ) ;
96
+
97
+ anim . AddClip ( clip , "test" ) ;
98
+
99
+ //export the object
100
+ var exported = FbxExporters . Editor . ModelExporter . ExportObject ( filename , go ) ;
101
+
102
+ Assert . That ( exported , Is . EqualTo ( filename ) ) ;
103
+
104
+ // TODO: Uni-34492 change importer settings of (newly exported model)
105
+ // so that it's not resampled and it is legacy animation
106
+ {
107
+ ModelImporter modelImporter = AssetImporter . GetAtPath ( filename ) as ModelImporter ;
108
+ Assert . That ( modelImporter , Is . Not . Null ) ;
109
+ modelImporter . resampleCurves = false ;
110
+ AssetDatabase . ImportAsset ( filename ) ;
111
+ modelImporter . animationType = ModelImporterAnimationType . Legacy ;
112
+ AssetDatabase . ImportAsset ( filename ) ;
113
+ }
114
+
115
+ Object [ ] objects = AssetDatabase . LoadAllAssetsAtPath ( filename ) ;
116
+
117
+ AnimationClip exportedClip = null ;
118
+ foreach ( Object o in objects )
119
+ {
120
+ exportedClip = o as AnimationClip ;
121
+ if ( exportedClip != null ) break ;
122
+ }
59
123
60
124
Assert . IsNotNull ( exportedClip ) ;
125
+ exportedClip . legacy = true ;
126
+
61
127
EditorCurveBinding exportedEditorCurveBinding = AnimationUtility . GetCurveBindings ( exportedClip ) [ 0 ] ;
62
128
63
129
AnimationCurve exportedCurve = AnimationUtility . GetEditorCurve ( exportedClip , exportedEditorCurveBinding ) ;
0 commit comments