docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ObservationWriter

    Allows sensors to write to both TensorProxy and float arrays/lists.

    Inheritance
    object
    ObservationWriter
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.MLAgents.Sensors
    Assembly: Unity.ML-Agents.dll
    Syntax
    public class ObservationWriter

    Constructors

    ObservationWriter()

    Initializes a new instance of the ObservationWriter class.

    Declaration
    public ObservationWriter()

    Properties

    this[int]

    1D write access at a specified index. Use AddList if possible instead.

    Declaration
    public float this[int index] { set; }
    Parameters
    Type Name Description
    int index

    Index to write to.

    Property Value
    Type Description
    float

    this[int, int]

    Write access at the specified channel and width.

    Declaration
    public float this[int ch, int w] { set; }
    Parameters
    Type Name Description
    int ch

    Channels

    int w

    Width

    Property Value
    Type Description
    float

    this[int, int, int]

    3D write access at the specified height, width, and channel.

    Declaration
    public float this[int ch, int h, int w] { set; }
    Parameters
    Type Name Description
    int ch

    Channels

    int h

    Height

    int w

    Width

    Property Value
    Type Description
    float

    Methods

    Add(Quaternion, int)

    Write the Quaternion components.

    Declaration
    public void Add(Quaternion quat, int writeOffset = 0)
    Parameters
    Type Name Description
    Quaternion quat

    The Quaternion to be written.

    int writeOffset

    Optional write offset.

    Add(Vector3, int)

    Write the Vector3 components.

    Declaration
    public void Add(Vector3 vec, int writeOffset = 0)
    Parameters
    Type Name Description
    Vector3 vec

    The Vector3 to be written.

    int writeOffset

    Optional write offset.

    Add(Vector4, int)

    Write the Vector4 components.

    Declaration
    public void Add(Vector4 vec, int writeOffset = 0)
    Parameters
    Type Name Description
    Vector4 vec

    The Vector4 to be written.

    int writeOffset

    Optional write offset.

    AddList(IList<float>, int)

    Write the list of floats.

    Declaration
    public void AddList(IList<float> data, int writeOffset = 0)
    Parameters
    Type Name Description
    IList<float> data

    The actual list of floats to write.

    int writeOffset

    Optional write offset to start writing from.

    Extension Methods

    ObservationWriterExtension.WriteTexture(ObservationWriter, Texture2D, bool)
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)