1
+ using UnityEngine ;
2
+ using UnityEditor ;
3
+ using NUnit . Framework ;
4
+
5
+ namespace FbxExporters . UnitTests
6
+ {
7
+ public class FbxCameraTest : ExporterTestBase
8
+ {
9
+
10
+ [ Test ]
11
+ public void AnimationWithCameraFOVTest ( )
12
+ {
13
+ string filename = GetRandomFbxFilePath ( ) ;
14
+ GameObject go = new GameObject ( ) ;
15
+ go . name = "originalCamera" ;
16
+ Camera camera = go . AddComponent ( typeof ( Camera ) ) as Camera ;
17
+ Animation anim = go . AddComponent ( typeof ( Animation ) ) as Animation ;
18
+ Keyframe [ ] keys = new Keyframe [ 3 ] ;
19
+ keys [ 0 ] = new Keyframe ( 0.0f , 1f ) ;
20
+ keys [ 1 ] = new Keyframe ( 1.0f , 2f ) ;
21
+ keys [ 2 ] = new Keyframe ( 2.0f , 3f ) ;
22
+
23
+ AnimationCurve curve = new AnimationCurve ( keys ) ;
24
+
25
+ AnimationClip clip = new AnimationClip ( ) ;
26
+
27
+ clip . legacy = true ;
28
+
29
+ clip . SetCurve ( "" , typeof ( Camera ) , "field of view" , curve ) ;
30
+
31
+ anim . AddClip ( clip , "test" ) ;
32
+
33
+ //export the object
34
+ var exported = FbxExporters . Editor . ModelExporter . ExportObject ( filename , go ) ;
35
+
36
+ Assert . That ( exported , Is . EqualTo ( filename ) ) ;
37
+
38
+ // TODO: Uni-34492 change importer settings of (newly exported model)
39
+ // so that it's not resampled and it is legacy animation
40
+ {
41
+ ModelImporter modelImporter = AssetImporter . GetAtPath ( filename ) as ModelImporter ;
42
+ Assert . That ( modelImporter , Is . Not . Null ) ;
43
+ modelImporter . resampleCurves = false ;
44
+ AssetDatabase . ImportAsset ( filename ) ;
45
+ modelImporter . animationType = ModelImporterAnimationType . Legacy ;
46
+ AssetDatabase . ImportAsset ( filename ) ;
47
+ }
48
+
49
+ Object [ ] objects = AssetDatabase . LoadAllAssetsAtPath ( filename ) ;
50
+
51
+ AnimationClip exportedClip = null ;
52
+ foreach ( Object o in objects )
53
+ {
54
+ exportedClip = o as AnimationClip ;
55
+ if ( exportedClip != null ) break ;
56
+ }
57
+
58
+ Assert . IsNotNull ( exportedClip ) ;
59
+ exportedClip . legacy = true ;
60
+
61
+ EditorCurveBinding exportedEditorCurveBinding = AnimationUtility . GetCurveBindings ( exportedClip ) [ 0 ] ;
62
+
63
+ AnimationCurve exportedCurve = AnimationUtility . GetEditorCurve ( exportedClip , exportedEditorCurveBinding ) ;
64
+
65
+ Assert . That ( exportedCurve . keys . Length , Is . EqualTo ( keys . Length ) ) ;
66
+
67
+ for ( int i = 0 ; i < exportedCurve . keys . Length ; i ++ )
68
+ {
69
+ Assert . That ( exportedCurve . keys [ i ] . time == keys [ i ] . time ) ;
70
+ Assert . That ( exportedCurve . keys [ i ] . value == keys [ i ] . value ) ;
71
+ }
72
+ }
73
+
74
+ }
75
+ }
0 commit comments