1
+ // NOTE: comment out the next line to leave temporary FBX files on disk
2
+ // #define DEBUG_UNITTEST
3
+
1
4
using UnityEngine ;
2
5
using UnityEditor ;
3
6
using NUnit . Framework ;
@@ -77,11 +80,11 @@ public static IEnumerable TestCases4 {
77
80
// specify continuous rotations
78
81
public static IEnumerable TestCases5 {
79
82
get {
80
- yield return new TestCaseData ( RotationInterpolation . kEuler /*use euler values*/ , m_keytimes5 , m_keyPosValues5 , m_keyRotValues5 ) . Returns ( 3 ) ;
83
+ yield return new TestCaseData ( RotationInterpolation . kEuler /*use euler values*/ , m_keytimes5 , m_keyPosValues5 , m_keyRotValues5 ) . Returns ( 6 ) ;
81
84
// Uni-35616 can't programmatically define a Euler (Quaternion) mix.
82
85
// yield return new TestCaseData (RotationInterpolation.kMixed /*use euler+quaternion values*/, m_keytimes5, m_keyPosValues5, m_keyRotValues5).Returns (3);
83
86
// Uni-35616 doesn't work with quaternions; rotations don't exceed 180
84
- // yield return new TestCaseData (RotationInterpolation.kQuaternion /*use quaternion values*/, m_keytimes5, m_keyPosValues5, m_keyRotValues5).Returns (3 );
87
+ yield return new TestCaseData ( RotationInterpolation . kQuaternion /*use quaternion values*/ , m_keytimes5 , m_keyPosValues5 , m_keyRotValues5 ) . Returns ( 6 ) ;
85
88
}
86
89
}
87
90
@@ -112,8 +115,9 @@ public class FbxAnimationTest : ExporterTestBase
112
115
[ TearDown ]
113
116
public override void Term ( )
114
117
{
115
- // NOTE: comment out the next line to leave temporary FBX files on disk
118
+ #if ( ! DEBUG_UNITTEST )
116
119
base . Term ( ) ;
120
+ #endif
117
121
}
118
122
119
123
protected void AnimClipPropertyTest ( AnimationClip animClipExpected , AnimationClip animClipActual )
@@ -384,6 +388,13 @@ public int AnimTest (KeyData keyData, string testName)
384
388
AssetDatabase . ImportAsset ( path ) ;
385
389
}
386
390
391
+ // create a scene GO so we can compare.
392
+ #if DEBUG_UNITTEST
393
+ GameObject prefabGO = AssetDatabase . LoadMainAssetAtPath ( path ) as GameObject ;
394
+ GameObject sceneGO = Object . Instantiate ( prefabGO , keyData . targetObject . transform . localPosition , keyData . targetObject . transform . localRotation ) ;
395
+ sceneGO . name = "Imported_" + testName ;
396
+ #endif
397
+
387
398
//acquire imported object from exported file
388
399
AnimationClip animClipImported = GetClipFromFbx ( path ) ;
389
400
@@ -392,23 +403,31 @@ public int AnimTest (KeyData keyData, string testName)
392
403
// check animCurve & keys
393
404
int result = 0 ;
394
405
406
+ // keyed localEulerAnglesRaw.z m_LocalRotation.z -1
395
407
foreach ( EditorCurveBinding curveBinding in AnimationUtility . GetCurveBindings ( animClipImported ) ) {
396
408
AnimationCurve animCurveImported = AnimationUtility . GetEditorCurve ( animClipImported , curveBinding ) ;
397
409
Assert . That ( animCurveImported , Is . Not . Null ) ;
398
410
399
- string altPropertyName ;
411
+ string altBinding ;
412
+
413
+ MapAltPropertyName . TryGetValue ( curveBinding . propertyName , out altBinding ) ;
400
414
401
- MapAltPropertyName . TryGetValue ( curveBinding . propertyName , out altPropertyName ) ;
415
+ bool hasAltBinding = ! string . IsNullOrEmpty ( altBinding ) ;
402
416
403
- bool hasAltPropertyName = ! string . IsNullOrEmpty ( altPropertyName ) ;
417
+ if ( ! hasAltBinding )
418
+ altBinding = curveBinding . propertyName ;
404
419
405
- if ( ! hasAltPropertyName )
406
- altPropertyName = curveBinding . propertyName ;
420
+ int id = keyData . GetIndexOf ( curveBinding . propertyName ) ;
407
421
408
- int id = keyData . GetIndexOf ( altPropertyName ) ;
422
+ if ( id == - 1 )
423
+ id = keyData . GetIndexOf ( altBinding ) ;
424
+
425
+ #if DEBUG_UNITTEST
426
+ Debug . Log ( string . Format ( "animtest binding={0} altBinding={1} id={2}" , curveBinding . propertyName , altBinding , id ) ) ;
427
+ #endif
409
428
410
429
if ( id != - 1 ) {
411
- AnimCurveTest ( keyData . keyTimesInSeconds , hasAltPropertyName ? keyData . GetAltKeyValues ( id ) : keyData . GetKeyValues ( id ) , animCurveImported , curveBinding . propertyName ) ;
430
+ AnimCurveTest ( keyData . keyTimesInSeconds , hasAltBinding ? keyData . GetAltKeyValues ( id ) : keyData . GetKeyValues ( id ) , animCurveImported , curveBinding . propertyName ) ;
412
431
result ++ ;
413
432
}
414
433
}
@@ -491,6 +510,8 @@ public void LegacySkinnedMeshAnimTest (string fbxPath)
491
510
AnimCurveTest ( animCurveImported , animCurveOrig , curveBinding . propertyName ) ;
492
511
}
493
512
}
513
+
514
+
494
515
}
495
516
496
517
[ Test , TestCaseSource ( typeof ( AnimationTestDataClass ) , "TestCases1" ) ]
0 commit comments