diff --git a/com.unity.ml-agents/CHANGELOG.md b/com.unity.ml-agents/CHANGELOG.md index 6ce7edfbba..158e6dde2d 100755 --- a/com.unity.ml-agents/CHANGELOG.md +++ b/com.unity.ml-agents/CHANGELOG.md @@ -38,6 +38,7 @@ and this project adheres to ### Bug Fixes #### com.unity.ml-agents / com.unity.ml-agents.extensions (C#) +- Fixed a bug where ml-agents code wouldn't compile on platforms that didn't support analytics (PS4/5, XBoxOne) (#5628) #### ml-agents / ml-agents-envs / gym-unity (Python) - Fixed a bug where the critics were not being normalized during training. (#5595) diff --git a/com.unity.ml-agents/Runtime/Analytics/InferenceAnalytics.cs b/com.unity.ml-agents/Runtime/Analytics/InferenceAnalytics.cs index 18d5fc62f8..b7b466155a 100644 --- a/com.unity.ml-agents/Runtime/Analytics/InferenceAnalytics.cs +++ b/com.unity.ml-agents/Runtime/Analytics/InferenceAnalytics.cs @@ -7,7 +7,7 @@ using Unity.MLAgents.Sensors; using UnityEngine; -#if MLA_UNITY_ANALYTICS_MODULE +#if MLA_UNITY_ANALYTICS_MODULE && ENABLE_CLOUD_SERVICES_ANALYTICS using UnityEngine.Analytics; #endif @@ -44,7 +44,7 @@ internal class InferenceAnalytics const int k_MaxNumberOfElements = 1000; -#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE +#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE && ENABLE_CLOUD_SERVICES_ANALYTICS /// /// Models that we've already sent events for. /// @@ -53,7 +53,7 @@ internal class InferenceAnalytics static bool EnableAnalytics() { -#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE +#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE && ENABLE_CLOUD_SERVICES_ANALYTICS if (s_EventRegistered) { return true; @@ -106,7 +106,7 @@ public static void InferenceModelSet( IList actuators ) { -#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE +#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE && ENABLE_CLOUD_SERVICES_ANALYTICS // The event shouldn't be able to report if this is disabled but if we know we're not going to report // Lets early out and not waste time gathering all the data if (!IsAnalyticsEnabled()) diff --git a/com.unity.ml-agents/Runtime/Analytics/TrainingAnalytics.cs b/com.unity.ml-agents/Runtime/Analytics/TrainingAnalytics.cs index 1b12dcf5d4..08c205bfc6 100644 --- a/com.unity.ml-agents/Runtime/Analytics/TrainingAnalytics.cs +++ b/com.unity.ml-agents/Runtime/Analytics/TrainingAnalytics.cs @@ -5,7 +5,11 @@ using Unity.MLAgents.Sensors; using UnityEngine; #if MLA_UNITY_ANALYTICS_MODULE + +#if ENABLE_CLOUD_SERVICES_ANALYTICS using UnityEngine.Analytics; +#endif + #if UNITY_EDITOR using UnityEditor.Analytics; #endif @@ -43,7 +47,7 @@ internal static class TrainingAnalytics private static bool s_SentEnvironmentInitialized; -#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE +#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE && ENABLE_CLOUD_SERVICES_ANALYTICS /// /// Whether or not we've registered this particular event yet /// @@ -64,7 +68,7 @@ internal static class TrainingAnalytics internal static bool EnableAnalytics() { -#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE +#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE && ENABLE_CLOUD_SERVICES_ANALYTICS if (s_EventsRegistered) { return true; @@ -106,7 +110,7 @@ public static void SetTrainerInformation(string packageVersion, string communica public static bool IsAnalyticsEnabled() { -#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE +#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE && ENABLE_CLOUD_SERVICES_ANALYTICS return EditorAnalytics.enabled; #else return false; @@ -135,7 +139,7 @@ public static void TrainingEnvironmentInitialized(TrainingEnvironmentInitialized // Debug.Log( // $"Would send event {k_TrainingEnvironmentInitializedEventName} with body {JsonUtility.ToJson(tbiEvent, true)}" // ); -#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE +#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE && ENABLE_CLOUD_SERVICES_ANALYTICS if (AnalyticsUtils.s_SendEditorAnalytics) { EditorAnalytics.SendEventWithLimit(k_TrainingEnvironmentInitializedEventName, tbiEvent); @@ -151,7 +155,7 @@ public static void RemotePolicyInitialized( IList actuators ) { -#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE +#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE && ENABLE_CLOUD_SERVICES_ANALYTICS if (!IsAnalyticsEnabled()) return; @@ -208,7 +212,7 @@ internal static TrainingBehaviorInitializedEvent SanitizeTrainingBehaviorInitial [Conditional("MLA_UNITY_ANALYTICS_MODULE")] public static void TrainingBehaviorInitialized(TrainingBehaviorInitializedEvent rawTbiEvent) { -#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE +#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE && ENABLE_CLOUD_SERVICES_ANALYTICS if (!IsAnalyticsEnabled()) return;