Class AnimationCurveSampler
Returns random values according to a range and probability distribution denoted by a user provided AnimationCurve. The X axis of the AnimationCurve 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.
Namespace: UnityEngine.Perception.Randomization.Samplers
Syntax
public class AnimationCurveSampler : object, ISampler
Constructors
AnimationCurveSampler()
Constructs a default AnimationCurveSampler
Declaration
public AnimationCurveSampler()
AnimationCurveSampler(AnimationCurve, Int32)
Constructs an AnimationCurveSampler with a given animation curve
Declaration
public AnimationCurveSampler(AnimationCurve curve, int numberOfSamples = 500)
Parameters
Type | Name | Description |
---|---|---|
AnimationCurve | curve | The animation curve to sample from |
Int32 | numberOfSamples | Number of samples used for integrating over the provided AnimationCurve |
Fields
distributionCurve
The Animation Curve associated with this sampler
Declaration
public AnimationCurve distributionCurve
Field Value
Type | Description |
---|---|
AnimationCurve |
numOfSamplesForIntegration
Number of samples used for integrating over the provided AnimationCurve. The larger the number of samples, the more accurate the resulting probability distribution will be.
Declaration
public int numOfSamplesForIntegration
Field Value
Type | Description |
---|---|
Int32 |
Properties
maxAllowed
The largest value this sampler should output
Declaration
public float maxAllowed { get; set; }
Property Value
Type | Description |
---|---|
Single |
Implements
minAllowed
The smallest value this sampler should output
Declaration
public float minAllowed { get; set; }
Property Value
Type | Description |
---|---|
Single |
Implements
shouldCheckValidRange
Whether the provided minAllowed and maxAllowed values should be used to validate this sampler.
Declaration
public bool shouldCheckValidRange { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
Methods
CheckAgainstValidRange()
Declaration
public void CheckAgainstValidRange()
Implements
Sample()
Generates one sample
Declaration
public float Sample()
Returns
Type | Description |
---|---|
Single | The generated sample |
Implements
Validate()
Validates that the sampler is configured properly
Declaration
public void Validate()
Implements
Exceptions
Type | Condition |
---|---|
UnityEngine.Perception.Randomization.Samplers.SamplerValidationException |