From 2bf0b3a6dbdd875103bdc68e07b5c715db53b1bc Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Wed, 17 Feb 2021 13:10:15 -0800 Subject: [PATCH 1/2] update defines, compile out Initialize body on non-desktop --- .../Runtime/Communicator/RpcCommunicator.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs b/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs index 6929ae6899..47f38bedb8 100644 --- a/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs +++ b/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs @@ -1,3 +1,7 @@ +#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX +#define MLA_SUPPORTED_TRAINING_PLATFORM +#endif + # if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX using Grpc.Core; #endif @@ -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; From e209b2554902a207265dd70c5df70be00b8f816c Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Wed, 17 Feb 2021 13:13:11 -0800 Subject: [PATCH 2/2] define --- com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs b/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs index 47f38bedb8..8dd1bbcac0 100644 --- a/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs +++ b/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs @@ -2,7 +2,7 @@ #define MLA_SUPPORTED_TRAINING_PLATFORM #endif -# if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX +# if MLA_SUPPORTED_TRAINING_PLATFORM using Grpc.Core; #endif #if UNITY_EDITOR