From 68fa1462a2daec452f47e803a27c340d97fd2dec Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Wed, 17 Feb 2021 18:53:24 -0800 Subject: [PATCH] update defines, compile out Initialize body on non-desktop (#4957) --- .../Runtime/Communicator/RpcCommunicator.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs b/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs index 6929ae6899..8dd1bbcac0 100644 --- a/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs +++ b/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs @@ -1,4 +1,8 @@ -# if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX +#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX +#define MLA_SUPPORTED_TRAINING_PLATFORM +#endif + +# if MLA_SUPPORTED_TRAINING_PLATFORM using Grpc.Core; #endif #if UNITY_EDITOR @@ -44,7 +48,7 @@ internal class RpcCommunicator : ICommunicator Dictionary m_UnsentBrainKeys = new Dictionary(); -#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX +#if MLA_SUPPORTED_TRAINING_PLATFORM /// The Unity to External client. UnityToExternalProto.UnityToExternalProtoClient m_Client; #endif @@ -97,6 +101,7 @@ string pythonApiVersion /// The External Initialization Parameters received. public bool Initialize(CommunicatorInitParameters initParameters, out UnityRLInitParameters initParametersOut) { +#if MLA_SUPPORTED_TRAINING_PLATFORM var academyParameters = new UnityRLInitializationOutputProto { Name = initParameters.name, @@ -183,6 +188,10 @@ out input UpdateEnvironmentWithInput(input.RlInput); initParametersOut = initializationInput.RlInitializationInput.ToUnityRLInitParameters(); return true; +#else + initParametersOut = new UnityRLInitParameters(); + return false; +#endif } /// @@ -213,7 +222,7 @@ void UpdateEnvironmentWithInput(UnityRLInputProto rlInput) UnityInputProto Initialize(UnityOutputProto unityOutput, out UnityInputProto unityInput) { -#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX +#if MLA_SUPPORTED_TRAINING_PLATFORM m_IsOpen = true; var channel = new Channel( "localhost:" + m_CommunicatorInitParameters.port, @@ -246,7 +255,7 @@ UnityInputProto Initialize(UnityOutputProto unityOutput, out UnityInputProto uni /// public void Dispose() { -#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX +#if MLA_SUPPORTED_TRAINING_PLATFORM if (!m_IsOpen) { return; @@ -447,7 +456,7 @@ public ActionBuffers GetActions(string behaviorName, int agentId) /// The UnityOutput to be sent. UnityInputProto Exchange(UnityOutputProto unityOutput) { -#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX +#if MLA_SUPPORTED_TRAINING_PLATFORM if (!m_IsOpen) { return null;