Class CategoricalParameter<T>
Generates samples by choosing one option from a list of choices
Inherited Members
Namespace: UnityEngine.Perception.Randomization.Parameters
Assembly: Unity.Perception.Runtime.dll
Syntax
[Serializable]
public class CategoricalParameter<T> : CategoricalParameterBase
Type Parameters
| Name | Description |
|---|---|
| T | The sample type of the categorical parameter |
Properties
Count
Returns the number of stored categories
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int | The number of stored categories |
categories
Returns a list of the potential categories this parameter can generate
Declaration
public IReadOnlyList<(T, float)> categories { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<(T, float)> |
sampleType
The sample type generated by this parameter
Declaration
public override sealed Type sampleType { get; }
Property Value
| Type | Description |
|---|---|
| Type |
Overrides
samplers
Returns an IEnumerable that iterates over each sampler field in this parameter
Declaration
public override IEnumerable<ISampler> samplers { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<ISampler> |
Overrides
Methods
GenericSample()
Generates a generic sample
Declaration
public override object GenericSample()
Returns
| Type | Description |
|---|---|
| object | The generated sample |
Overrides
GetCategory(int)
Returns the category stored at the specified index
Declaration
public T GetCategory(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index of the category to lookup |
Returns
| Type | Description |
|---|---|
| T | The category stored at the specified index |
GetCategoryCount()
Returns the number of stored categories
Declaration
[Obsolete("GetCategoryCount method has been deprecated. Please use Count (UnityUpgradable)")]
public int GetCategoryCount()
Returns
| Type | Description |
|---|---|
| int | The number of stored categories |
GetProbability(int)
Returns the probability value stored at the specified index
Declaration
public float GetProbability(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index of the probability value to lookup |
Returns
| Type | Description |
|---|---|
| float | 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, float)>)
Updates this parameter's list of categorical options
Declaration
public void SetOptions(IEnumerable<(T, float)> categoricalOptions)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<(T, float)> | categoricalOptions | The categorical options to configure |
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 |
Validate()
Validates the categorical probabilities assigned to this parameter
Declaration
public override void Validate()
Overrides
Exceptions
| Type | Condition |
|---|---|
| ParameterValidationException |