@@ -217,6 +217,38 @@ public int TestWeightAnimation(float[] keyTimes, float[] keyValues, string prope
217
217
return tester . DoIt ( ) ;
218
218
}
219
219
220
+ [ Test ]
221
+ public void TestDontExportSource ( )
222
+ {
223
+ // test that no error occurs if a source is not exported
224
+ var constrained = new GameObject ( "constrained" ) ;
225
+ var source1 = new GameObject ( "source1" ) ;
226
+ var source2 = new GameObject ( "source2" ) ;
227
+ var source3 = new GameObject ( "source3" ) ;
228
+
229
+ var constraint = SetupConstraintWithSources < PositionConstraint > ( constrained , new List < GameObject > ( ) { source1 , source2 , source3 } ) ;
230
+
231
+ // don't export source2
232
+ var exportedGO = ExportConstraints ( new Object [ ] { constrained , source1 , source3 } ) ;
233
+
234
+ // get exported constraint
235
+ var expConstraint = exportedGO . GetComponentInChildren < PositionConstraint > ( ) ;
236
+ Assert . That ( expConstraint , Is . Not . Null ) ;
237
+
238
+ var origSources = new List < ConstraintSource > ( ) ;
239
+ constraint . GetSources ( origSources ) ;
240
+
241
+ var expSources = new List < ConstraintSource > ( ) ;
242
+ expConstraint . GetSources ( expSources ) ;
243
+
244
+ Assert . That ( expSources . Count , Is . EqualTo ( origSources . Count - 1 ) ) ;
245
+
246
+ Assert . That ( expSources [ 0 ] . sourceTransform , Is . EqualTo ( origSources [ 0 ] . sourceTransform ) ) ;
247
+ Assert . That ( expSources [ 0 ] . weight , Is . EqualTo ( origSources [ 0 ] . weight ) ) ;
248
+ Assert . That ( expSources [ 1 ] . sourceTransform , Is . EqualTo ( origSources [ 2 ] . sourceTransform ) ) ;
249
+ Assert . That ( expSources [ 1 ] . weight , Is . EqualTo ( origSources [ 2 ] . weight ) ) ;
250
+ }
251
+
220
252
public bool AreEqual ( Vector3 a , Vector3 b , double epsilon = 0.0001 )
221
253
{
222
254
return Vector3 . SqrMagnitude ( a - b ) < epsilon ;
0 commit comments