using UnityEngine; namespace MLAgents.Sensors { /// /// Component that wraps a . /// [AddComponentMenu("ML Agents/Render Texture Sensor", (int)MenuGroup.Sensors)] public class RenderTextureSensorComponent : SensorComponent { /// /// The instance that the associated /// wraps. /// public RenderTexture renderTexture; /// /// Name of the sensor. /// public string sensorName = "RenderTextureSensor"; /// /// Whether the RenderTexture observation should be converted to grayscale or not. /// public bool grayscale; /// /// Compression type for the render texture observation. /// public SensorCompressionType compression = SensorCompressionType.PNG; /// public override ISensor CreateSensor() { return new RenderTextureSensor(renderTexture, grayscale, sensorName, compression); } /// public override int[] GetObservationShape() { var width = renderTexture != null ? renderTexture.width : 0; var height = renderTexture != null ? renderTexture.height : 0; return new[] { height, width, grayscale ? 1 : 3 }; } } }