Merge pull request #31 from unity/additonal_scenario_configs
Additional scenario configs:
- Ability to add valid ranges for all samplers (except for animation curve sampler)
- Ability to add valid range to non sampler numeric scalars through the [Range] attribute
- A new compile definition symbol for exposing the valid ranges of samplers in the scenario UI
- Ability to enable or disable a randomizer through the app-param (for this to work, the already existing enabled property is serialized and deserialized. Code was added to treat properties the same as fields during (de)serialization to achieve this)
- New flag in randomizers to denote whether their enabled state can be switched by the user on datamaker. This is purely used on datamaker.
Added new configuration options to the Scenario JSON configuration. These include a `limits` block on numerical Scalars and Samplers to denote a valid range, and a `state` block on the Randomizers for enabling/disabling them from the config.
The user can now choose the base folder location to store their generated datasets.
Added the AssetSource class for loading assets from generic sources inside randomizers.
/// Some Randomizers should not be disabled by the user as they are critical to the project. E.g. We might want to mark this as false for a foreground objects placement randomizer in some projects
[Tooltip("Probability distribution curve used for this sampler. The X axis corresponds to the values this sampler will pick from, and the Y axis corresponds to the relative probability of the values. The relative probabilities (Y axis) do not need to max out at 1 as only the shape of the curve matters. The Y values cannot however be negative.")]
publicAnimationCurvedistributionCurve;
publicvoidCheckAgainstValidRange()
{
thrownewNotImplementedException();
//no range check currently performed for this sampler
}
///<inheritdoc/>
[field: HideInInspector]
[field: SerializeField]
publicfloatminAllowed{get;set;}
///<inheritdoc/>
[field: HideInInspector]
[field: SerializeField]
publicfloatmaxAllowed{get;set;}
///<inheritdoc/>
[field: HideInInspector]
[field: SerializeField]
publicboolshouldCheckValidRange{get;set;}
/// <summary>
/// Number of samples used for integrating over the provided AnimationCurve.
/// <param name="value">The value from which samples will be generated</param>
publicConstantSampler(floatvalue)
/// <param name="shouldCheckValidRange">Whether the provided <see cref="minAllowed"/> and <see cref="maxAllowed"/> values should be used to validate the <see cref="value"/> provided</param>
/// <param name="minAllowed">The smallest min value allowed for this range</param>
/// <param name="maxAllowed">The largest max value allowed for this range</param>
/// <param name="mean">The mean of the normal distribution to sample from</param>
/// <param name="standardDeviation">The standard deviation of the normal distribution to sample from</param>
/// <param name="shouldCheckValidRange">Whether the provided <see cref="minAllowed"/> and <see cref="maxAllowed"/> values should be used to validate the range provided with <see cref="minimum"/> and <see cref="maximum"/></param>
/// <param name="minAllowed">The smallest min value allowed for this range</param>
/// <param name="maxAllowed">The largest max value allowed for this range</param>
/// A range bounding the values generated by this sampler
/// </summary>
publicFloatRangerange;
///<inheritdoc/>
#if !SCENARIO_CONFIG_POWER_USER
[field: HideInInspector]
#endif
[field: SerializeField]
publicfloatminAllowed{get;set;}
///<inheritdoc/>
#if !SCENARIO_CONFIG_POWER_USER
[field: HideInInspector]
#endif
[field: SerializeField]
publicfloatmaxAllowed{get;set;}
///<inheritdoc/>
#if !SCENARIO_CONFIG_POWER_USER
[field: HideInInspector]
#endif
[field: SerializeField]
publicboolshouldCheckValidRange{get;set;}
/// <summary>
/// Constructs a UniformSampler
/// </summary>
/// <param name="min">The smallest value contained within the range</param>
/// <param name="max">The largest value contained within the range</param>
publicUniformSampler(floatmin,floatmax)
/// <param name="shouldCheckValidRange">Whether the provided <see cref="minAllowed"/> and <see cref="maxAllowed"/> values should be used to validate the range provided with <see cref="minimum"/> and <see cref="maximum"/></param>
/// <param name="minAllowed">The smallest min value allowed for this range</param>
/// <param name="maxAllowed">The largest max value allowed for this range</param>
//the field has a range attribute and the json has a limits block for this field, but the numbers don't match
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.");
}
elseif(readScalar.Item2==null)
{
//the field has a range attribute but the json has no limits block for this field
Debug.LogError($"The provided Scenario JSON specifies limits for the field \"{field.Name}\" of \"{obj.GetType().Name}\", while the field has no Range attribute in the code. Ranges for scalar fields can only be set in code using the Range attribute and not from the Scenario JSON.");
Debug.LogError($"The provided value for the field \"{field.Name}\" of \"{obj.GetType().Name}\" exceeds the allowed valid range. Clamping to valid range.");
//the field does not have a range attribute but the json has a limits block for this field
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.");