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

37 行
1.3 KiB

using System;
using Unity.Simulation;
namespace UnityEngine.Experimental.Perception.Randomization.Scenarios
{
/// <summary>
/// Defines a scenario that is compatible with the Run in Unity Simulation window
/// </summary>
/// <typeparam name="T">The type of constants to serialize</typeparam>
public abstract class UnitySimulationScenario<T> : Scenario<T> where T : UnitySimulationScenarioConstants, new()
{
/// <summary>
/// Returns whether the entire scenario has completed
/// </summary>
public sealed override bool isScenarioComplete => currentIteration >= constants.totalIterations;
/// <summary>
/// Progresses the current scenario iteration
/// </summary>
protected sealed override void IncrementIteration()
{
currentIteration += constants.instanceCount;
}
/// <summary>
/// Deserializes this scenario's constants from the Unity Simulation AppParams Json file
/// </summary>
public sealed override void Deserialize()
{
if (Configuration.Instance.IsSimulationRunningInCloud())
constants = Configuration.Instance.GetAppParams<T>();
else
base.Deserialize();
currentIteration = constants.instanceIndex;
}
}
}