using System; using Unity.Simulation; namespace UnityEngine.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() { /// public sealed override bool isScenarioComplete => currentIteration >= constants.totalIterations; /// protected sealed override void IncrementIteration() { currentIteration += constants.instanceCount; } /// protected override void OnAwake() { // Don't skip the first frame if executing on Unity Simulation if (Configuration.Instance.IsSimulationRunningInCloud()) m_SkipFrame = false; } /// protected override void OnStart() { if (Configuration.Instance.IsSimulationRunningInCloud()) { DeserializeFromFile(new Uri(Configuration.Instance.SimulationConfig.app_param_uri).LocalPath); constants.instanceIndex = int.Parse(Configuration.Instance.GetInstanceId()) - 1; } else base.OnStart(); currentIteration = constants.instanceIndex; } } }