@@ -2144,6 +2144,44 @@ public AnimationOnlyExportData(
2144
2144
this . exportComponent = exportComponent ;
2145
2145
this . defaultClip = null ;
2146
2146
}
2147
+
2148
+ public void ComputeObjectsInAnimationClips (
2149
+ AnimationClip [ ] animClips ,
2150
+ GameObject animationRootObject
2151
+ ) {
2152
+ // TODO: find a better way to keep track of which components + properties we support
2153
+ var cameraProps = new List < string > { "field of view" } ;
2154
+ var lightProps = new List < string > { "m_Intensity" , "m_SpotAngle" , "m_Color.r" , "m_Color.g" , "m_Color.b" } ;
2155
+
2156
+ foreach ( var animClip in animClips ) {
2157
+ if ( this . animationClips . ContainsKey ( animClip ) ) {
2158
+ // we have already exported gameobjects for this clip
2159
+ continue ;
2160
+ }
2161
+
2162
+ this . animationClips . Add ( animClip , animationRootObject ) ;
2163
+
2164
+ foreach ( EditorCurveBinding uniCurveBinding in AnimationUtility . GetCurveBindings ( animClip ) ) {
2165
+ Object uniObj = AnimationUtility . GetAnimatedObject ( animationRootObject , uniCurveBinding ) ;
2166
+ if ( ! uniObj ) {
2167
+ continue ;
2168
+ }
2169
+
2170
+ GameObject unityGo = GetGameObject ( uniObj ) ;
2171
+ if ( ! unityGo ) {
2172
+ continue ;
2173
+ }
2174
+
2175
+ if ( lightProps . Contains ( uniCurveBinding . propertyName ) ) {
2176
+ this . exportComponent . Add ( unityGo , typeof ( Light ) ) ;
2177
+ } else if ( cameraProps . Contains ( uniCurveBinding . propertyName ) ) {
2178
+ this . exportComponent . Add ( unityGo , typeof ( Camera ) ) ;
2179
+ }
2180
+
2181
+ this . goExportSet . Add ( unityGo ) ;
2182
+ }
2183
+ }
2184
+ }
2147
2185
}
2148
2186
2149
2187
/// <summary>
@@ -2468,7 +2506,7 @@ out Dictionary<GameObject, AnimationOnlyExportData> hierarchyToExportData
2468
2506
}
2469
2507
2470
2508
var animClips = AnimationUtility . GetAnimationClips ( anim . gameObject ) ;
2471
- GetObjectsInAnimationClips ( animClips , anim . gameObject , ref exportData ) ;
2509
+ exportData . ComputeObjectsInAnimationClips ( animClips , anim . gameObject ) ;
2472
2510
}
2473
2511
2474
2512
int aFromRoot = int . MaxValue ;
@@ -2485,7 +2523,7 @@ out Dictionary<GameObject, AnimationOnlyExportData> hierarchyToExportData
2485
2523
var controller = anim . runtimeAnimatorController ;
2486
2524
if ( controller )
2487
2525
{
2488
- GetObjectsInAnimationClips ( controller . animationClips , anim . gameObject , ref exportData ) ;
2526
+ exportData . ComputeObjectsInAnimationClips ( controller . animationClips , anim . gameObject ) ;
2489
2527
}
2490
2528
}
2491
2529
@@ -2526,45 +2564,6 @@ out Dictionary<GameObject, AnimationOnlyExportData> hierarchyToExportData
2526
2564
return completeExpSet . Count ;
2527
2565
}
2528
2566
2529
- protected void GetObjectsInAnimationClips (
2530
- AnimationClip [ ] animClips ,
2531
- GameObject animationRootObject ,
2532
- ref AnimationOnlyExportData exportData
2533
- ) {
2534
- // TODO: find a better way to keep track of which components + properties we support
2535
- var cameraProps = new List < string > { "field of view" } ;
2536
- var lightProps = new List < string > { "m_Intensity" , "m_SpotAngle" , "m_Color.r" , "m_Color.g" , "m_Color.b" } ;
2537
-
2538
- foreach ( var animClip in animClips ) {
2539
- if ( exportData . animationClips . ContainsKey ( animClip ) ) {
2540
- // we have already exported gameobjects for this clip
2541
- continue ;
2542
- }
2543
-
2544
- exportData . animationClips . Add ( animClip , animationRootObject ) ;
2545
-
2546
- foreach ( EditorCurveBinding uniCurveBinding in AnimationUtility . GetCurveBindings ( animClip ) ) {
2547
- Object uniObj = AnimationUtility . GetAnimatedObject ( animationRootObject , uniCurveBinding ) ;
2548
- if ( ! uniObj ) {
2549
- continue ;
2550
- }
2551
-
2552
- GameObject unityGo = GetGameObject ( uniObj ) ;
2553
- if ( ! unityGo ) {
2554
- continue ;
2555
- }
2556
-
2557
- if ( lightProps . Contains ( uniCurveBinding . propertyName ) ) {
2558
- exportData . exportComponent . Add ( unityGo , typeof ( Light ) ) ;
2559
- } else if ( cameraProps . Contains ( uniCurveBinding . propertyName ) ) {
2560
- exportData . exportComponent . Add ( unityGo , typeof ( Camera ) ) ;
2561
- }
2562
-
2563
- exportData . goExportSet . Add ( unityGo ) ;
2564
- }
2565
- }
2566
- }
2567
-
2568
2567
/// <summary>
2569
2568
/// Export components on this game object.
2570
2569
/// Transform components have already been exported.
0 commit comments