Class CategoricalParameter<T>
Generates samples by choosing one option from a list of choices
Inherited Members
Namespace: UnityEngine.Experimental.Perception.Randomization.Parameters
Syntax
[Serializable]
public abstract class CategoricalParameter<T> : CategoricalParameterBase
Type Parameters
Name | Description |
---|---|
T | The sample type of the categorical parameter |
Properties
categories
Returns a list of the potential categories this parameter can generate
Declaration
public IReadOnlyList<(T, float)> categories { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<ValueTuple<T, Single>> |
sampleType
The sample type generated by this parameter
Declaration
public override sealed Type sampleType { get; }
Property Value
Type | Description |
---|---|
Type |
Overrides
Methods
GenericSample()
Generates a generic sample
Declaration
public override object GenericSample()
Returns
Type | Description |
---|---|
Object | The generated sample |
Overrides
GetCategory(Int32)
Returns the category stored at the specified index
Declaration
public T GetCategory(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index of the category to lookup |
Returns
Type | Description |
---|---|
T | The category stored at the specified index |
GetProbability(Int32)
Returns the probability value stored at the specified index
Declaration
public float GetProbability(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index of the probability value to lookup |
Returns
Type | Description |
---|---|
Single | The probability value stored at the specified index |
Sample()
Generates a sample
Declaration
public T Sample()
Returns
Type | Description |
---|---|
T | The generated sample |
SetOptions(IEnumerable<T>)
Updates this parameter's list of categorical options
Declaration
public void SetOptions(IEnumerable<T> categoricalOptions)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | categoricalOptions | The categorical options to configure |
SetOptions(IEnumerable<(T, Single)>)
Updates this parameter's list of categorical options
Declaration
public void SetOptions(IEnumerable<(T, float)> categoricalOptions)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<ValueTuple<T, Single>> | categoricalOptions | The categorical options to configure |
Validate()
Validates the categorical probabilities assigned to this parameter
Declaration
public override void Validate()
Overrides
Exceptions
Type | Condition |
---|---|
UnityEngine.Experimental.Perception.Randomization.Parameters.ParameterValidationException |