docs.unity3d.com
    Show / Hide Table of Contents

    Class RenderTextureSensor

    Sensor class that wraps a RenderTexture instance.

    Inheritance
    Object
    RenderTextureSensor
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.MLAgents.Sensors
    Syntax
    public class RenderTextureSensor : ISensor, IBuiltInSensor, IDisposable

    Constructors

    RenderTextureSensor(RenderTexture, Boolean, String, SensorCompressionType)

    Initializes the sensor.

    Declaration
    public RenderTextureSensor(RenderTexture renderTexture, bool grayscale, string name, SensorCompressionType compressionType)
    Parameters
    Type Name Description
    RenderTexture renderTexture

    The RenderTexture instance to wrap.

    Boolean grayscale

    Whether to convert it to grayscale or not.

    String name

    Name of the sensor.

    SensorCompressionType 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
    SensorCompressionType

    Methods

    Dispose()

    Clean up the owned Texture2D.

    Declaration
    public void Dispose()
    Implements
    IDisposable.Dispose()

    GetBuiltInSensorType()

    Declaration
    public BuiltInSensorType GetBuiltInSensorType()
    Returns
    Type Description
    BuiltInSensorType

    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.

    Implements
    ISensor.GetCompressedObservation()

    GetCompressionSpec()

    Return information on the compression type being used. If no compression is used, return Default().

    Declaration
    public CompressionSpec GetCompressionSpec()
    Returns
    Type Description
    CompressionSpec

    An object describing the compression used by the sensor.

    Implements
    ISensor.GetCompressionSpec()

    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.

    Implements
    ISensor.GetName()

    GetObservationSpec()

    Returns a description of the observations that will be generated by the sensor. See ObservationSpec for more details, and helper methods to create one.

    Declaration
    public ObservationSpec GetObservationSpec()
    Returns
    Type Description
    ObservationSpec

    An object describing the observation.

    Implements
    ISensor.GetObservationSpec()

    ObservationToTexture(RenderTexture, Texture2D)

    Converts a RenderTexture to a 2D texture.

    Declaration
    public static void ObservationToTexture(RenderTexture obsTexture, Texture2D texture2D)
    Parameters
    Type Name Description
    RenderTexture 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()
    Implements
    ISensor.Reset()

    Update()

    Update any internal state of the sensor. This is called once per each agent step.

    Declaration
    public void Update()
    Implements
    ISensor.Update()

    Write(ObservationWriter)

    Write the observation data directly to the ObservationWriter. Note that this (and GetCompressedObservation()) may be called multiple times per agent step, so should not mutate any internal state.

    Declaration
    public int Write(ObservationWriter writer)
    Parameters
    Type Name Description
    ObservationWriter writer

    Where the observations will be written to.

    Returns
    Type Description
    Int32

    The number of elements written.

    Implements
    ISensor.Write(ObservationWriter)

    Extension Methods

    SensorExtensions.ObservationSize(ISensor)
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023