@@ -361,13 +361,24 @@ public void TestExportCamera(){
361
361
/// <param name="filename">Filename.</param>
362
362
/// <param name="cameraObj">Camera object.</param>
363
363
private Camera ExportCamera ( string filename , GameObject cameraObj ) {
364
- ModelExporter . ExportObject ( filename , cameraObj ) ;
364
+ ExportComponent < Camera > ( filename , cameraObj ) ;
365
+ }
366
+
367
+ /// <summary>
368
+ /// Exports the GameObject and returns component of type T.
369
+ /// </summary>
370
+ /// <returns>The component.</returns>
371
+ /// <param name="filename">Filename.</param>
372
+ /// <param name="obj">Object.</param>
373
+ /// <typeparam name="T">The component type.</typeparam>
374
+ private T ExportComponent < T > ( string filename , GameObject obj ) where T : Component {
375
+ ModelExporter . ExportObject ( filename , obj ) ;
365
376
366
377
GameObject fbxObj = AssetDatabase . LoadMainAssetAtPath ( filename ) as GameObject ;
367
- var fbxCamera = fbxObj . GetComponent < Camera > ( ) ;
378
+ var fbxComponent = fbxObj . GetComponent < T > ( ) ;
368
379
369
- Assert . IsNotNull ( fbxCamera ) ;
370
- return fbxCamera ;
380
+ Assert . IsNotNull ( fbxComponent ) ;
381
+ return fbxComponent ;
371
382
}
372
383
373
384
private void CompareCameraValues ( Camera camera , Camera fbxCamera , float delta = 0.001f ) {
@@ -376,5 +387,35 @@ private void CompareCameraValues(Camera camera, Camera fbxCamera, float delta=0.
376
387
Assert . AreEqual ( camera . nearClipPlane , fbxCamera . nearClipPlane , delta ) ;
377
388
Assert . AreEqual ( camera . farClipPlane , fbxCamera . farClipPlane , delta ) ;
378
389
}
390
+
391
+ [ Test ]
392
+ public void TestExportLight ( )
393
+ {
394
+ // create a Unity light
395
+ GameObject lightObj = new GameObject ( "TestLight" ) ;
396
+ Light light = lightObj . AddComponent < Light > ( ) ;
397
+
398
+ light . type = LightType . Spot ;
399
+ light . spotAngle = 55.4f ;
400
+ light . color = Color . blue ;
401
+ light . intensity = 2.3f ;
402
+ light . range = 45 ;
403
+ light . shadows = LightShadows . Soft ;
404
+
405
+ string filename = GetRandomFbxFilePath ( ) ;
406
+ var fbxLight = ExportComponent < Light > ( filename , lightObj ) ;
407
+ CompareLightValues ( light , fbxLight ) ;
408
+ }
409
+
410
+ private void CompareLightValues ( Light light , Light fbxLight , float delta = 0.001f ) {
411
+ Assert . AreEqual ( light . type , fbxLight . type ) ;
412
+ if ( light . type == LightType . Spot ) {
413
+ Assert . AreEqual ( light . spotAngle , fbxLight . spotAngle , delta ) ;
414
+ }
415
+ Assert . AreEqual ( light . color , fbxLight . color ) ;
416
+ Assert . AreEqual ( light . intensity , fbxLight . intensity , delta ) ;
417
+ Assert . AreEqual ( light . range , fbxLight . range , delta ) ;
418
+ // compare shadows
419
+ }
379
420
}
380
421
}
0 commit comments