@@ -136,5 +136,72 @@ public void AnimationWithLightIntensityTest()
136
136
Assert . That ( exportedCurve . keys [ i ] . value == keys [ i ] . value ) ;
137
137
}
138
138
}
139
+
140
+ [ Test ]
141
+ public void AnimationWithLightColorTest ( )
142
+ {
143
+ string filename = GetRandomFbxFilePath ( ) ;
144
+ GameObject go = new GameObject ( ) ;
145
+ go . name = "original" ;
146
+ Light light = go . AddComponent ( typeof ( Light ) ) as Light ;
147
+ Animation anim = go . AddComponent ( typeof ( Animation ) ) as Animation ;
148
+
149
+ Keyframe [ ] keys = new Keyframe [ 3 ] ;
150
+ keys [ 0 ] = new Keyframe ( 0.0f , 0.0f ) ;
151
+ keys [ 1 ] = new Keyframe ( 1.0f , 0.5f ) ;
152
+ keys [ 2 ] = new Keyframe ( 2.0f , 1.0f ) ;
153
+
154
+ AnimationCurve curve = new AnimationCurve ( keys ) ;
155
+
156
+ AnimationClip clip = new AnimationClip ( ) ;
157
+
158
+ clip . legacy = true ;
159
+
160
+ clip . SetCurve ( "" , typeof ( Light ) , "m_Color.r" , curve ) ;
161
+ clip . SetCurve ( "" , typeof ( Light ) , "m_Color.g" , curve ) ;
162
+ clip . SetCurve ( "" , typeof ( Light ) , "m_Color.b" , curve ) ;
163
+
164
+ anim . AddClip ( clip , "test" ) ;
165
+
166
+ //export the object
167
+ var exported = FbxExporters . Editor . ModelExporter . ExportObject ( filename , go ) ;
168
+
169
+ Assert . That ( exported , Is . EqualTo ( filename ) ) ;
170
+
171
+ // TODO: Uni-34492 change importer settings of (newly exported model)
172
+ // so that it's not resampled and it is legacy animation
173
+ {
174
+ ModelImporter modelImporter = AssetImporter . GetAtPath ( filename ) as ModelImporter ;
175
+ Assert . That ( modelImporter , Is . Not . Null ) ;
176
+ modelImporter . resampleCurves = false ;
177
+ AssetDatabase . ImportAsset ( filename ) ;
178
+ modelImporter . animationType = ModelImporterAnimationType . Legacy ;
179
+ AssetDatabase . ImportAsset ( filename ) ;
180
+ }
181
+
182
+ Object [ ] objects = AssetDatabase . LoadAllAssetsAtPath ( filename ) ;
183
+
184
+ AnimationClip exportedClip = null ;
185
+ foreach ( Object o in objects )
186
+ {
187
+ exportedClip = o as AnimationClip ;
188
+ if ( exportedClip != null ) break ;
189
+ }
190
+
191
+ Assert . IsNotNull ( exportedClip ) ;
192
+ exportedClip . legacy = true ;
193
+
194
+ EditorCurveBinding exportedEditorCurveBinding = AnimationUtility . GetCurveBindings ( exportedClip ) [ 0 ] ;
195
+
196
+ AnimationCurve exportedCurve = AnimationUtility . GetEditorCurve ( exportedClip , exportedEditorCurveBinding ) ;
197
+
198
+ Assert . That ( exportedCurve . keys . Length , Is . EqualTo ( keys . Length ) ) ;
199
+
200
+ for ( int i = 0 ; i < exportedCurve . keys . Length ; i ++ )
201
+ {
202
+ Assert . That ( exportedCurve . keys [ i ] . time == keys [ i ] . time ) ;
203
+ Assert . That ( exportedCurve . keys [ i ] . value == keys [ i ] . value ) ;
204
+ }
205
+ }
139
206
}
140
207
}
0 commit comments