Skip to content

Commit d59d1aa

Browse files
mkamalzaaryan-mann
authored andcommitted
Update ScenarioSerializer.cs
1 parent ab8c752 commit d59d1aa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

com.unity.perception/Runtime/Randomization/Scenarios/Serialization/ScenarioSerializer.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ static void DeserializeScalarValue(object obj, FieldInfo field, Scalar scalar)
325325
if (rangeAttribute != null)
326326
{
327327
if (readScalar.Item2 != null &&
328-
(Math.Abs(rangeAttribute.min - readScalar.Item2.max) > tolerance || Math.Abs(rangeAttribute.max - readScalar.Item2.max) > tolerance))
328+
(Math.Abs(rangeAttribute.min - readScalar.Item2.min) > tolerance || Math.Abs(rangeAttribute.max - readScalar.Item2.max) > tolerance))
329329
{
330330
//the field has a range attribute and the json has a limits block for this field, but the numbers don't match
331331
Debug.LogError($"The limits provided in the Scenario JSON for the field \"{field.Name}\" of \"{obj.GetType().Name}\" do not match this field's range set in the code. Ranges for scalar fields can only be set in code using the Range attribute and not from the Scenario JSON.");
@@ -348,6 +348,8 @@ static void DeserializeScalarValue(object obj, FieldInfo field, Scalar scalar)
348348
if (readScalar.Item2 != null)
349349
//the field does not have a range attribute but the json has a limits block for this field
350350
Debug.LogError($"The provided Scenario JSON specifies limits for the field \"{field.Name}\" of \"{obj.GetType().Name}\", but the field has no Range attribute in code. Ranges for scalar fields can only be set in code using the Range attribute and not from the Scenario JSON.");
351+
352+
field.SetValue(obj, Convert.ChangeType(readScalar.Item1, field.FieldType));
351353
}
352354

353355
}

0 commit comments

Comments
 (0)