docs.unity3d.com
    Show / Hide Table of Contents

    Class SideChannel

    Side channels provide an alternative mechanism of sending/receiving data from Unity to Python that is outside of the traditional machine learning loop. ML-Agents provides some specific implementations of side channels, but users can create their own.

    To create your own, you'll need to create two, new mirrored classes, one in Unity (by extending SideChannel) and another in Python by extending a Python class also called SideChannel. Then, within your project, use RegisterSideChannel(SideChannel) and UnregisterSideChannel(SideChannel) to register and unregister your custom side channel.

    Inheritance
    Object
    SideChannel
    FloatPropertiesChannel
    RawBytesChannel
    Namespace: Unity.MLAgents.SideChannels
    Syntax
    public abstract class SideChannel : object

    Properties

    ChannelId

    An int identifier for the SideChannel. Ensures that there is only ever one side channel of each type. Ensure the Unity side channels will be linked to their Python equivalent.

    Declaration
    public Guid ChannelId { get; protected set; }
    Property Value
    Type Description
    Guid

    The integer identifier of the SideChannel.

    Methods

    OnMessageReceived(IncomingMessage)

    Is called by the communicator every time a message is received from Python by the SideChannel. Can be called multiple times per simulation step if multiple messages were sent.

    Declaration
    protected abstract void OnMessageReceived(IncomingMessage msg)
    Parameters
    Type Name Description
    IncomingMessage msg

    The incoming message.

    QueueMessageToSend(OutgoingMessage)

    Queues a message to be sent to Python during the next simulation step.

    Declaration
    protected void QueueMessageToSend(OutgoingMessage msg)
    Parameters
    Type Name Description
    OutgoingMessage msg

    The byte array of data to be sent to Python.

    In This Article
    • Properties
      • ChannelId
    • Methods
      • OnMessageReceived(IncomingMessage)
      • QueueMessageToSend(OutgoingMessage)
    Back to top
    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