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