Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Side Channel example brakes unity editor #SideChannel

Discussion in 'ML-Agents' started by alonsh, Apr 18, 2020.

  1. alonsh

    alonsh

    Joined:
    Sep 22, 2017
    Posts:
    3
    Hi,
    I'm trying to use side channel with the unity editor
    I'm using build 15.0 release on windows 10 home with anaconda.
    I'm able to connect with the unity and example Ball3D, but when I'm trying to add a side channel and connect to the env using the python API and jupyter notebook, the editor get stuck (need to kill process) and the
    get timeout in the notebook.

    I've used the code example from the docs to create a new SttringLogSideChannel
    In the unity side and in the python side as shown in the costume side channel.
    Also in this release, the SideChannelUtils class was removed so I had to create it.

    any assistance will help.
    thanks!
     
  2. alonsh

    alonsh

    Joined:
    Sep 22, 2017
    Posts:
    3
    figured out the issue, the documentation is wrong.
    in Custom-SideChannels.md the RegisterStringLogSideChannel is using a removed class, and the class you need to register to is the Academy.

    Code (CSharp):
    1. public class RegisterStringLogSideChannel : MonoBehaviour
    2. {
    3.  
    4.     StringLogSideChannel stringChannel;
    5.     public void Awake()
    6.     {
    7.         // We create the Side Channel
    8.         stringChannel = new StringLogSideChannel();
    9.  
    10.         // When a Debug.Log message is created, we send it to the stringChannel
    11.         Application.logMessageReceived += stringChannel.SendDebugStatementToPython;
    12.  
    13.         // The channel must be registered with the SideChannelUtils class
    14.         SideChannelUtils.RegisterSideChannel(stringChannel);
    15.     }
    16.  
    17.     public void OnDestroy()
    18.     {
    19.         // De-register the Debug.Log callback
    20.         Application.logMessageReceived -= stringChannel.SendDebugStatementToPython;
    21.         if (Academy.IsInitialized){
    22.             SideChannelUtils.UnregisterSideChannel(stringChannel);
    23.         }
    24.     }
    it should be:
    Code (CSharp):
    1. public class RegisterStringLogSideChannel : MonoBehaviour
    2. {
    3.     Academy academy;
    4.     StringLogSideChannel stringChannel;
    5.     public void Awake()
    6.     {
    7.         // We create the Side Channel
    8.         stringChannel = new StringLogSideChannel();
    9.  
    10.         // When a Debug.Log message is created, we send it to the stringChannel
    11.         Application.logMessageReceived += stringChannel.SendDebugStatementToPython;
    12.  
    13.         // The channel must be registered with the SideChannelUtils class
    14.       academy = Academy.Instance;
    15.       academy.RegisterSideChannel(sideChannel);
    16.     }
    17.  
    18.     public void OnDestroy()
    19.     {
    20.         // De-register the Debug.Log callback
    21.         Application.logMessageReceived -= stringChannel.SendDebugStatementToPython;
    22.         if (Academy.IsInitialized){
    23.             academy.UnregisterSideChannel(stringChannel);
    24.         }
    25.     }
     
    Last edited: Apr 19, 2020
  3. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,840
    I'll flag this for the team! Thanks!
     
  4. vincentpierre

    vincentpierre

    Joined:
    May 5, 2017
    Posts:
    160
    alonsh likes this.