/// <summary> /// Initialize the communicator by sending the first UnityOutput and receiving the /// first UnityInput. The second UnityInput is stored in the unityInput argument. /// </summary> /// <returns>The first Unity Input.</returns> /// <param name="unityOutput">The first Unity Output.</param> /// <param name="unityInput">The second Unity input.</param> public UnityInput Initialize(UnityOutput unityOutput, out UnityInput unityInput) { m_isOpen = true; var channel = new Channel( "localhost:" + m_communicatorParameters.port, ChannelCredentials.Insecure); m_client = new UnityToExternal.UnityToExternalClient(channel); var result = m_client.Exchange(WrapMessage(unityOutput, 200)); unityInput = m_client.Exchange(WrapMessage(null, 200)).UnityInput; #if UNITY_EDITOR EditorApplication.playModeStateChanged += HandleOnPlayModeChanged; #endif return(result.UnityInput); }