using System;
using System.Collections.Generic;
using UnityEngine.Perception.GroundTruth;
using UnityEngine.Perception.Randomization.Parameters;
using UnityEngine.Perception.Randomization.Samplers;
namespace UnityEngine.Perception.Randomization.Scenarios
{
///
/// A scenario that runs for a fixed number of frames during each iteration
///
[AddComponentMenu("Perception/Scenarios/Fixed Length Scenario")]
public class FixedLengthScenario: UnitySimulationScenario
{
protected PerceptionCamera m_PerceptionCamera;
///
/// Constants describing the execution of this scenario
///
[Serializable]
public class Constants : UnitySimulationScenarioConstants
{
///
/// The number of frames to render per iteration.
///
[Tooltip("The number of frames to render per iteration.")]
public int framesPerIteration = 1;
}
///
/// Returns whether the current scenario iteration has completed
///
protected override bool isIterationComplete => currentIterationFrame >= constants.framesPerIteration;
///
protected override void OnAwake()
{
base.OnAwake();
m_PerceptionCamera = FindObjectOfType();
if (m_PerceptionCamera != null && m_PerceptionCamera.captureTriggerMode != CaptureTriggerMode.Manual)
{
Debug.LogError("The perception camera must be set to manual capture mode", m_PerceptionCamera);
m_PerceptionCamera.enabled = false;
enabled = false;
}
}
///
protected override void OnUpdate()
{
if (m_PerceptionCamera && currentIterationFrame == constants.framesPerIteration - 1)
{
m_PerceptionCamera.RequestCapture();
}
}
}
}