Class RenderTextureSensor
Sensor class that wraps a RenderTexture instance.
Inherited Members
Namespace: Unity.MLAgents.Sensors
Assembly: Unity.ML-Agents.dll
Syntax
public class RenderTextureSensor : ISensor, IDisposable
Constructors
RenderTextureSensor(RenderTexture, bool, string, SensorCompressionType)
Initializes the sensor.
Declaration
public RenderTextureSensor(RenderTexture renderTexture, bool grayscale, string name, SensorCompressionType compressionType)
Parameters
Type | Name | Description |
---|---|---|
Render |
renderTexture | The RenderTexture instance to wrap. |
bool | grayscale | Whether to convert it to grayscale or not. |
string | name | Name of the sensor. |
Sensor |
compressionType | Compression method for the render texture. |
Properties
CompressionType
The compression type used by the sensor.
Declaration
public SensorCompressionType CompressionType { get; set; }
Property Value
Type | Description |
---|---|
Sensor |
Methods
Dispose()
Clean up the owned Texture2D.
Declaration
public void Dispose()
GetBuiltInSensorType()
Return the corresponding BuiltInSensorType for the sensor.
Declaration
public BuiltInSensorType GetBuiltInSensorType()
Returns
Type | Description |
---|---|
Built |
A BuiltInSensorType corresponding to the sensor. |
GetCompressedObservation()
Return a compressed representation of the observation. For small observations, this should generally not be implemented. However, compressing large observations (such as visual results) can significantly improve model training time.
Declaration
public byte[] GetCompressedObservation()
Returns
Type | Description |
---|---|
byte[] | Compressed observation. |
GetCompressionSpec()
Return information on the compression type being used. If no compression is used, return Default().
Declaration
public CompressionSpec GetCompressionSpec()
Returns
Type | Description |
---|---|
Compression |
An object describing the compression used by the sensor. |
GetName()
Get the name of the sensor. This is used to ensure deterministic sorting of the sensors on an Agent, so the naming must be consistent across all sensors and agents.
Declaration
public string GetName()
Returns
Type | Description |
---|---|
string | The name of the sensor. |
GetObservationSpec()
Returns a description of the observations that will be generated by the sensor.
See Observation
Declaration
public ObservationSpec GetObservationSpec()
Returns
Type | Description |
---|---|
Observation |
An object describing the observation. |
ObservationToTexture(RenderTexture, Texture2D)
Converts a RenderTexture to a 2D texture.
Declaration
public static void ObservationToTexture(RenderTexture obsTexture, Texture2D texture2D)
Parameters
Type | Name | Description |
---|---|---|
Render |
obsTexture | RenderTexture. |
Texture2D | texture2D | Texture2D to render to. |
Reset()
Resets the internal state of the sensor. This is called at the end of an Agent's episode. Most implementations can leave this empty.
Declaration
public void Reset()
Update()
Update any internal state of the sensor. This is called once per each agent step.
Declaration
public void Update()
Write(ObservationWriter)
Write the observation data directly to the Observation
Declaration
public int Write(ObservationWriter writer)
Parameters
Type | Name | Description |
---|---|---|
Observation |
writer | Where the observations will be written to. |
Returns
Type | Description |
---|---|
int | The number of elements written. |