Skip to content

Commit a108b29

Browse files
author
Austin Jubrey
committed
[ADDED] unit test for exporting an animation driven light with ONE parameter
1 parent 5a8cb05 commit a108b29

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

Assets/FbxExporters/Editor/UnitTests/FbxPrefabTest.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,62 @@ GameObject ModifySourceFbx()
221221
return newModel;
222222
}
223223

224+
[Test]
225+
public void AnimationWithLightTest()
226+
{
227+
string filename = GetRandomFbxFilePath ();
228+
GameObject go = new GameObject ();
229+
Light light = go.AddComponent(typeof (Light)) as Light;
230+
Animation anim = go.AddComponent (typeof(Animation)) as Animation;
231+
232+
Keyframe[] keys;
233+
keys = new Keyframe[3];
234+
keys[0] = new Keyframe(0.0f, 0.25f);
235+
keys[1] = new Keyframe(1.0f, 0.5f);
236+
keys[2] = new Keyframe(2.0f, 1.0f);
237+
238+
AnimationCurve curve = new AnimationCurve (keys);
239+
240+
AnimationClip clip = new AnimationClip ();
241+
242+
clip.legacy = true;
243+
244+
clip.SetCurve ("", typeof(Light), "m_Intensity", curve);
245+
246+
anim.AddClip (clip, "test");
247+
248+
//export the object
249+
var exported = FbxExporters.Editor.ModelExporter.ExportObject(filename , go);
250+
251+
//acquire exported file
252+
GameObject asset = AssetDatabase.LoadMainAssetAtPath(filename) as GameObject;
253+
254+
//access the exported game objects' light
255+
Light foundLight = asset.GetComponent (typeof(Light)) as Light;
256+
257+
//Check that the light exists
258+
Assert.IsNotNull (foundLight);
259+
260+
//Set the time of the animation to 0 seconds
261+
clip.SampleAnimation(asset, 0.0f);
262+
263+
//check that the value matches the key at 0 seconds
264+
Assert.AreEqual (foundLight.intensity, 0.25f);
265+
266+
//Set the time of the animation to 1 second
267+
clip.SampleAnimation(asset, 1.0f);
268+
269+
//check that the value matches the key at 1 second
270+
Assert.AreEqual (foundLight.intensity, 0.5f);
271+
272+
//Set the time of the animation to 2 seconds
273+
clip.SampleAnimation(asset, 2.0f);
274+
275+
//check that the value matches the key at 2 seconds
276+
Assert.AreEqual (foundLight.intensity, 1.0f);
277+
278+
}
279+
224280
[Test]
225281
public void BasicTest() {
226282
// Verify we start in the right place.

0 commit comments

Comments
 (0)