您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

44 行
1.3 KiB

using System;
using UnityEngine.Scripting.APIUpdating;
namespace UnityEngine.Perception.Randomization.Parameters
{
/// <summary>
/// Numeric parameters use samplers to generate randomized structs
/// </summary>
/// <typeparam name="T">The sample type of the parameter</typeparam>
[Serializable]
[MovedFrom("UnityEngine.Experimental.Perception.Randomization.Parameters")]
public abstract class NumericParameter<T> : Parameter where T : struct
{
/// <summary>
/// The sample type of parameter
/// </summary>
public sealed override Type sampleType => typeof(T);
/// <summary>
/// Generates one parameter sample
/// </summary>
/// <returns>The generated sample</returns>
public abstract T Sample();
/// <summary>
/// Generates a generic sample
/// </summary>
/// <returns>The generated sample</returns>
public override object GenericSample()
{
return Sample();
}
/// <summary>
/// Validate the settings of this parameter
/// </summary>
public override void Validate()
{
base.Validate();
foreach (var sampler in samplers)
sampler.Validate();
}
}
}