@@ -21,67 +21,61 @@ public override void EndRecording(RecordingSession session)
21
21
foreach ( var input in m_Inputs )
22
22
{
23
23
24
- var aInput = ( FbxInput ) input ;
24
+ var aInput = ( AnimationInput ) input ;
25
25
26
- var recorders = aInput . gameObjectRecorder ;
27
- var gameObjects = ( ( FbxInputSettings ) aInput . settings ) . gameObjects ;
28
- if ( recorders == null || recorders . Length <= 0 )
26
+ if ( aInput . gameObjectRecorder == null )
29
27
continue ;
30
28
31
- var clips = new AnimationClip [ recorders . Length ] ;
32
- for ( int i = 0 ; i < recorders . Length ; i ++ )
33
- {
34
- clips [ i ] = new AnimationClip ( ) ;
35
-
36
- ars . fileNameGenerator . CreateDirectory ( session ) ;
29
+ var clip = new AnimationClip ( ) ;
37
30
38
- var absolutePath = FileNameGenerator . SanitizePath ( ars . fileNameGenerator . BuildAbsolutePath ( session ) ) ;
39
- var clipName = absolutePath . Replace ( FileNameGenerator . SanitizePath ( Application . dataPath ) , "Assets" ) ;
31
+ ars . fileNameGenerator . CreateDirectory ( session ) ;
40
32
41
- //AssetDatabase.CreateAsset(clip, clipName);
42
- #if UNITY_2018_3_OR_NEWER
43
- recorders [ i ] . SaveToClip ( clips [ i ] , ars . frameRate ) ;
33
+ var absolutePath = FileNameGenerator . SanitizePath ( ars . fileNameGenerator . BuildAbsolutePath ( session ) ) ;
34
+ var clipName = absolutePath . Replace ( FileNameGenerator . SanitizePath ( Application . dataPath ) , "Assets" ) ;
35
+
36
+ //AssetDatabase.CreateAsset(clip, clipName);
37
+ #if UNITY_2018_3_OR_NEWER
38
+ aInput . gameObjectRecorder . SaveToClip ( clip , ars . frameRate ) ;
44
39
#else
45
- recorder . SaveToClip ( clip ) ;
40
+ aInput . gameObjectRecorder . SaveToClip ( clip ) ;
46
41
#endif
47
- var root = gameObjects [ i ] ;
48
- clips [ i ] . name = "recorded_clip" ;
49
- clips [ i ] . legacy = true ;
50
- Animation animator = root . GetComponent < Animation > ( ) ;
51
- bool hasAnimComponent = true ;
52
- if ( ! animator )
53
- {
54
- animator = root . AddComponent < Animation > ( ) ;
55
- hasAnimComponent = false ;
56
- }
42
+ var root = ( ( AnimationInputSettings ) aInput . settings ) . gameObject ;
43
+ clip . name = "recorded_clip" ;
44
+ clip . legacy = true ;
45
+ Animation animator = root . GetComponent < Animation > ( ) ;
46
+ bool hasAnimComponent = true ;
47
+ if ( ! animator )
48
+ {
49
+ animator = root . AddComponent < Animation > ( ) ;
50
+ hasAnimComponent = false ;
51
+ }
57
52
58
- AnimationClip [ ] prevAnimClips = null ;
59
- if ( hasAnimComponent )
60
- {
61
- prevAnimClips = AnimationUtility . GetAnimationClips ( root ) ;
62
- }
53
+ AnimationClip [ ] prevAnimClips = null ;
54
+ if ( hasAnimComponent )
55
+ {
56
+ prevAnimClips = AnimationUtility . GetAnimationClips ( root ) ;
57
+ }
63
58
64
- AnimationUtility . SetAnimationClips ( animator , new AnimationClip [ ] { clips [ i ] } ) ;
65
- var exportSettings = new ExportModelSettingsSerialize ( ) ;
66
- var toInclude = ExportSettings . Include . ModelAndAnim ;
67
- if ( ! ars . ExportGeometry )
68
- {
69
- toInclude = ExportSettings . Include . Anim ;
70
- }
71
- exportSettings . SetModelAnimIncludeOption ( toInclude ) ;
72
- ModelExporter . ExportObject ( clipName , root , exportSettings ) ;
59
+ AnimationUtility . SetAnimationClips ( animator , new AnimationClip [ ] { clip } ) ;
60
+ var exportSettings = new ExportModelSettingsSerialize ( ) ;
61
+ var toInclude = ExportSettings . Include . ModelAndAnim ;
62
+ if ( ! ars . ExportGeometry )
63
+ {
64
+ toInclude = ExportSettings . Include . Anim ;
65
+ }
66
+ exportSettings . SetModelAnimIncludeOption ( toInclude ) ;
67
+ ModelExporter . ExportObject ( clipName , root , exportSettings ) ;
73
68
74
69
75
- if ( hasAnimComponent )
76
- {
77
- AnimationUtility . SetAnimationClips ( animator , prevAnimClips ) ;
78
- }
79
- else
80
- {
81
- Object . DestroyImmediate ( animator ) ;
82
- }
83
- recorders [ i ] . ResetRecording ( ) ;
70
+ if ( hasAnimComponent )
71
+ {
72
+ AnimationUtility . SetAnimationClips ( animator , prevAnimClips ) ;
73
+ }
74
+ else
75
+ {
76
+ Object . DestroyImmediate ( animator ) ;
84
77
}
78
+ aInput . gameObjectRecorder . ResetRecording ( ) ;
85
79
}
86
80
base . EndRecording ( session ) ;
87
81
}
0 commit comments