diff --git a/Assets/Tests/InputSystem/CoreTests_Analytics.cs b/Assets/Tests/InputSystem/CoreTests_Analytics.cs index ef86b4fa64..e9892b3064 100644 --- a/Assets/Tests/InputSystem/CoreTests_Analytics.cs +++ b/Assets/Tests/InputSystem/CoreTests_Analytics.cs @@ -663,6 +663,55 @@ public void Analytics_ShouldReportPlayerInputManagerData() } } + [Test] + [Category("Analytics")] + public void Analytics_ShouldReportCodeAuthoringAnalytic() + { + CollectAnalytics(InputExitPlayModeAnalytic.kEventName); + + // NOTE: We do not want to trigger entering/exiting play-mode for this small data-sanity check + // so just stick to triggering it explicitly. A better test would have been an editor test + // going in and out of play-mode for real but not clear if this is really possible. + + // Pretend we are entering play-mode + InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingEditMode); + InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredPlayMode); + + // Assert no data received + Assert.That(sentAnalyticsEvents.Count, Is.EqualTo(0)); + + // Pretend we are exiting play-mode + InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingPlayMode); + InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredEditMode); + + // Assert: Data received + Assert.That(sentAnalyticsEvents.Count, Is.EqualTo(1)); + Assert.That(sentAnalyticsEvents[0].name, Is.EqualTo(InputExitPlayModeAnalytic.kEventName)); + Assert.That(sentAnalyticsEvents[0].data, Is.TypeOf()); + + var data0 = (InputExitPlayModeAnalytic.Data)sentAnalyticsEvents[0].data; + Assert.That(data0.uses_code_authoring, Is.False); + + // Pretend we are entering play-mode + InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingEditMode); + InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredPlayMode); + + var action = new InputAction("Dance"); + action.AddBinding("/Space"); + + // Pretend we are exiting play-mode + InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.ExitingPlayMode); + InputExitPlayModeAnalytic.OnPlayModeStateChange(PlayModeStateChange.EnteredEditMode); + + // Assert: Data received + Assert.That(sentAnalyticsEvents.Count, Is.EqualTo(2)); + Assert.That(sentAnalyticsEvents[1].name, Is.EqualTo(InputExitPlayModeAnalytic.kEventName)); + Assert.That(sentAnalyticsEvents[1].data, Is.TypeOf()); + + var data1 = (InputExitPlayModeAnalytic.Data)sentAnalyticsEvents[1].data; + Assert.That(data1.uses_code_authoring, Is.True); + } + #if UNITY_INPUT_SYSTEM_ENABLE_UI [Test] [Category("Analytics")] diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index 785f36c0c3..5a555b2373 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -47,6 +47,7 @@ however, it has to be formatted properly to pass verification tests. - Added tests for Input Action Editor UI for managing action maps (List, create, rename, delete) (ISX-2087) - Added automatic loading of custom extensions of InputProcessor, InputInteraction and InputBindingComposite [ISXB-856]](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-856). - Added an IME Input sample scene. +- Added analytics for programmatic `InputAction` setup via `InputActionSetupExtensions`. ## [1.10.0] - 2024-07-24 diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/InputActionSetupExtensions.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/InputActionSetupExtensions.cs index f5b087565d..6a1aa3e7a5 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/InputActionSetupExtensions.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/InputActionSetupExtensions.cs @@ -306,6 +306,23 @@ public static BindingSyntax AddBinding(this InputAction action, string path, str }); } + /// + /// Conditionally compiled helper for logging API usage of code-authored actions. + /// + /// The associated API function. + /// + /// Be extremely carefully to review for indirect calls and overloads to not register analytics twice. + /// Be extremely careful in enabling/disabling tracking before internal calls since those may otherwise + /// be incorrectly registered. + /// + #if UNITY_EDITOR + private static void RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api api) + { + UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Register(api); + } + + #endif + /// /// Add a binding that references the given and triggers /// the given . @@ -349,6 +366,10 @@ public static BindingSyntax AddBinding(this InputAction action, InputControl con /// public static BindingSyntax AddBinding(this InputAction action, InputBinding binding = default) { + #if UNITY_EDITOR + RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.AddBinding); + #endif + if (action == null) throw new ArgumentNullException(nameof(action)); @@ -478,6 +499,10 @@ public static BindingSyntax AddBinding(this InputActionMap actionMap, string pat /// public static BindingSyntax AddBinding(this InputActionMap actionMap, InputBinding binding) { + #if UNITY_EDITOR + RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.AddBinding); + #endif + if (actionMap == null) throw new ArgumentNullException(nameof(actionMap)); if (binding.path == null) @@ -501,6 +526,10 @@ public static BindingSyntax AddBinding(this InputActionMap actionMap, InputBindi public static CompositeSyntax AddCompositeBinding(this InputAction action, string composite, string interactions = null, string processors = null) { + #if UNITY_EDITOR + RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.AddCompositeBinding); + #endif + if (action == null) throw new ArgumentNullException(nameof(action)); if (string.IsNullOrEmpty(composite)) @@ -580,6 +609,10 @@ private static int AddBindingInternal(InputActionMap map, InputBinding binding, /// of ). public static BindingSyntax ChangeBinding(this InputAction action, int index) { + #if UNITY_EDITOR + RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ChangeBinding); + #endif + if (action == null) throw new ArgumentNullException(nameof(action)); @@ -638,6 +671,10 @@ public static BindingSyntax ChangeBinding(this InputAction action, string name) /// of ). public static BindingSyntax ChangeBinding(this InputActionMap actionMap, int index) { + #if UNITY_EDITOR + RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ChangeBinding); + #endif + if (actionMap == null) throw new ArgumentNullException(nameof(actionMap)); if (index < 0 || index >= actionMap.m_Bindings.LengthSafe()) @@ -836,6 +873,10 @@ public static BindingSyntax ChangeBinding(this InputAction action, InputBinding /// public static BindingSyntax ChangeCompositeBinding(this InputAction action, string compositeName) { + #if UNITY_EDITOR + RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ChangeCompositeBinding); + #endif + if (action == null) throw new ArgumentNullException(nameof(action)); if (string.IsNullOrEmpty(compositeName)) @@ -877,6 +918,10 @@ public static BindingSyntax ChangeCompositeBinding(this InputAction action, stri /// public static void Rename(this InputAction action, string newName) { + #if UNITY_EDITOR + RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.Rename); + #endif + if (action == null) throw new ArgumentNullException(nameof(action)); if (string.IsNullOrEmpty(newName)) @@ -919,6 +964,10 @@ public static void Rename(this InputAction action, string newName) /// public static void AddControlScheme(this InputActionAsset asset, InputControlScheme controlScheme) { + #if UNITY_EDITOR + RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.AddControlScheme); + #endif + if (asset == null) throw new ArgumentNullException(nameof(asset)); if (string.IsNullOrEmpty(controlScheme.name)) @@ -987,6 +1036,10 @@ public static ControlSchemeSyntax AddControlScheme(this InputActionAsset asset, /// public static void RemoveControlScheme(this InputActionAsset asset, string name) { + #if UNITY_EDITOR + RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.RemoveControlScheme); + #endif + if (asset == null) throw new ArgumentNullException(nameof(asset)); if (string.IsNullOrEmpty(name)) @@ -1007,11 +1060,19 @@ public static void RemoveControlScheme(this InputActionAsset asset, string name) /// public static InputControlScheme WithBindingGroup(this InputControlScheme scheme, string bindingGroup) { + #if UNITY_EDITOR + RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeWithBindingGroup); + #endif + return new ControlSchemeSyntax(scheme).WithBindingGroup(bindingGroup).Done(); } public static InputControlScheme WithDevice(this InputControlScheme scheme, string controlPath, bool required) { + #if UNITY_EDITOR + RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeWithDevice); + #endif + if (required) return new ControlSchemeSyntax(scheme).WithRequiredDevice(controlPath).Done(); return new ControlSchemeSyntax(scheme).WithOptionalDevice(controlPath).Done(); @@ -1019,21 +1080,37 @@ public static InputControlScheme WithDevice(this InputControlScheme scheme, stri public static InputControlScheme WithRequiredDevice(this InputControlScheme scheme, string controlPath) { + #if UNITY_EDITOR + RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeWithRequiredDevice); + #endif + return new ControlSchemeSyntax(scheme).WithRequiredDevice(controlPath).Done(); } public static InputControlScheme WithOptionalDevice(this InputControlScheme scheme, string controlPath) { + #if UNITY_EDITOR + RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeWithOptionalDevice); + #endif + return new ControlSchemeSyntax(scheme).WithOptionalDevice(controlPath).Done(); } public static InputControlScheme OrWithRequiredDevice(this InputControlScheme scheme, string controlPath) { + #if UNITY_EDITOR + RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeOrWithRequiredDevice); + #endif + return new ControlSchemeSyntax(scheme).OrWithRequiredDevice(controlPath).Done(); } public static InputControlScheme OrWithOptionalDevice(this InputControlScheme scheme, string controlPath) { + #if UNITY_EDITOR + RegisterApiUsage(UnityEngine.InputSystem.Editor.InputExitPlayModeAnalytic.Api.ControlSchemeOrWithOptionalDevice); + #endif + return new ControlSchemeSyntax(scheme).OrWithOptionalDevice(controlPath).Done(); } diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputActionsEditorSessionAnalytic.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputActionsEditorSessionAnalytic.cs index 2733dd0fca..a966aa18a0 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputActionsEditorSessionAnalytic.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputActionsEditorSessionAnalytic.cs @@ -178,7 +178,7 @@ public void End() #region IInputAnalytic Interface -#if UNITY_EDITOR && UNITY_2023_2_OR_NEWER +#if UNITY_2023_2_OR_NEWER public bool TryGatherData(out UnityEngine.Analytics.IAnalytic.IData data, out Exception error) #else public bool TryGatherData(out InputAnalytics.IInputAnalyticData data, out Exception error) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputBuildAnalytic.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputBuildAnalytic.cs index e2860d398e..40bb709409 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputBuildAnalytic.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputBuildAnalytic.cs @@ -31,7 +31,7 @@ public InputBuildAnalytic(BuildReport buildReport) public InputAnalytics.InputAnalyticInfo info => new InputAnalytics.InputAnalyticInfo(kEventName, kMaxEventsPerHour, kMaxNumberOfElements); -#if UNITY_EDITOR && UNITY_2023_2_OR_NEWER +#if UNITY_2023_2_OR_NEWER public bool TryGatherData(out UnityEngine.Analytics.IAnalytic.IData data, out Exception error) #else public bool TryGatherData(out InputAnalytics.IInputAnalyticData data, out Exception error) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputComponentEditorAnalytic.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputComponentEditorAnalytic.cs index d559e7618c..93aef1a521 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputComponentEditorAnalytic.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputComponentEditorAnalytic.cs @@ -72,7 +72,7 @@ public InputComponentEditorAnalytic(InputSystemComponent component) m_Component = component; } -#if UNITY_EDITOR && UNITY_2023_2_OR_NEWER +#if UNITY_2023_2_OR_NEWER public bool TryGatherData(out UnityEngine.Analytics.IAnalytic.IData data, out Exception error) #else public bool TryGatherData(out InputAnalytics.IInputAnalyticData data, out Exception error) @@ -86,4 +86,4 @@ public bool TryGatherData(out InputAnalytics.IInputAnalyticData data, out Except public InputAnalytics.InputAnalyticInfo info { get; } } } -#endif +#endif // UNITY_EDITOR diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputEditorAnalytics.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputEditorAnalytics.cs index 60bc676df3..a96861b7d2 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputEditorAnalytics.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputEditorAnalytics.cs @@ -4,7 +4,7 @@ namespace UnityEngine.InputSystem.Editor { - internal static partial class InputEditorAnalytics + internal static class InputEditorAnalytics { /// /// Represents notification behavior setting associated with and diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputExitPlayModeAnalytic.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputExitPlayModeAnalytic.cs new file mode 100644 index 0000000000..a978775bca --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputExitPlayModeAnalytic.cs @@ -0,0 +1,165 @@ +#if UNITY_EDITOR + +using System; +using UnityEditor; +using UnityEngine.Serialization; + +namespace UnityEngine.InputSystem.Editor +{ +#if UNITY_2023_2_OR_NEWER + [UnityEngine.Analytics.AnalyticInfo(eventName: kEventName, maxEventsPerHour: kMaxEventsPerHour, + maxNumberOfElements: kMaxNumberOfElements, vendorKey: UnityEngine.InputSystem.InputAnalytics.kVendorKey)] +#endif // UNITY_2023_2_OR_NEWER + internal class InputExitPlayModeAnalytic : UnityEngine.InputSystem.InputAnalytics.IInputAnalytic + { + public const string kEventName = "input_exit_playmode"; + public const int kMaxEventsPerHour = 100; // default: 1000 + public const int kMaxNumberOfElements = 100; // default: 1000 + + /// + /// Enumeration type for code authoring APIs mapping to . + /// + /// + /// This enumeration type may be added to, but NEVER changed, since it would break older data. + /// + public enum Api + { + AddBinding = 0, + AddCompositeBinding = 1, + ChangeBinding = 2, + ChangeCompositeBinding = 3, + Rename = 4, + AddControlScheme = 5, + RemoveControlScheme = 6, + ControlSchemeWithBindingGroup = 7, + ControlSchemeWithDevice = 8, + ControlSchemeWithRequiredDevice = 9, + ControlSchemeWithOptionalDevice = 10, + ControlSchemeOrWithRequiredDevice = 11, + ControlSchemeOrWithOptionalDevice = 12 + } + + private static readonly int[] m_Counters = new int[Enum.GetNames(typeof(Api)).Length]; + + /// + /// Registers a call to the associated API. + /// + /// Enumeration identifying the API. + public static void Register(Api api) + { + if (suppress) + return; + + // Note: Currently discards detailed information and only sets a boolean (aggregated) value. + ++m_Counters[(int)api]; + } + + /// + /// Suppresses the registration of analytics. + /// + /// + /// May be used to temporarily suppress analytics to avoid false positives from internal usage. + /// + public static bool suppress + { + get; set; + } + + // Cache delegate + private static readonly Action PlayModeChanged = OnPlayModeStateChange; + + // Note: Internal visibility to simplify unit testing + internal static void OnPlayModeStateChange(PlayModeStateChange change) + { + if (change == PlayModeStateChange.ExitingEditMode) + { + // Reset all counters when exiting edit mode + Array.Clear(m_Counters, 0, m_Counters.Length); + + // Make sure not suppressed + suppress = false; + } + if (change == PlayModeStateChange.ExitingPlayMode) + { + // Send analytics and unhook delegate when exiting play-mode + EditorApplication.playModeStateChanged -= PlayModeChanged; + new InputExitPlayModeAnalytic().Send(); + + // No reason to not suppress + suppress = true; + } + } + + [InitializeOnEnterPlayMode] + private static void Hook() + { + // Make sure only a single play-mode change delegate is registered + EditorApplication.playModeStateChanged -= PlayModeChanged; + EditorApplication.playModeStateChanged += PlayModeChanged; + } + + private InputExitPlayModeAnalytic() + { + info = new InputAnalytics.InputAnalyticInfo(kEventName, kMaxEventsPerHour, kMaxNumberOfElements); + } + + /// + /// Represents data collected when exiting play-mode.. + /// + /// + /// Ideally this struct should be readonly but then Unity cannot serialize/deserialize it. + /// + [Serializable] + public struct Data : UnityEngine.InputSystem.InputAnalytics.IInputAnalyticData + { + /// + /// Creates a new Data instance. + /// + /// Specifies whether code authoring has been used during play-mode. + public Data(bool usesCodeAuthoring) + { + uses_code_authoring = usesCodeAuthoring; + } + + /// + /// Specifies whether code-authoring (Input Action setup via extensions) was used at least once during play-mode. + /// + public bool uses_code_authoring; + } + +#if UNITY_2023_2_OR_NEWER + public bool TryGatherData(out UnityEngine.Analytics.IAnalytic.IData data, out Exception error) +#else + public bool TryGatherData(out InputAnalytics.IInputAnalyticData data, out Exception error) +#endif + { + try + { + // Determine aggregated perspective, i.e. was "any" code-authoring API used + var usedCodeAuthoringDuringPlayMode = false; + for (var i = 0; i < m_Counters.Length; ++i) + { + if (m_Counters[i] > 0) + { + usedCodeAuthoringDuringPlayMode = true; + break; + } + } + + data = new Data(usedCodeAuthoringDuringPlayMode); + error = null; + return true; + } + catch (Exception e) + { + data = null; + error = e; + return false; + } + } + + public InputAnalytics.InputAnalyticInfo info { get; } + } +} + +#endif // UNITY_EDITOR diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputExitPlayModeAnalytic.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputExitPlayModeAnalytic.cs.meta new file mode 100644 index 0000000000..dd7700a303 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputExitPlayModeAnalytic.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 07c4c48bac384a9e91c29c2f04328c0b +timeCreated: 1724231031 \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/OnScreenStickEditorAnalytic.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/OnScreenStickEditorAnalytic.cs index 964ef9173a..73ad50e788 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/OnScreenStickEditorAnalytic.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/OnScreenStickEditorAnalytic.cs @@ -66,7 +66,7 @@ public OnScreenStickEditorAnalytic(UnityEditor.Editor editor) m_Editor = editor; } -#if UNITY_EDITOR && UNITY_2023_2_OR_NEWER +#if UNITY_2023_2_OR_NEWER public bool TryGatherData(out UnityEngine.Analytics.IAnalytic.IData data, out Exception error) #else public bool TryGatherData(out InputAnalytics.IInputAnalyticData data, out Exception error) @@ -89,4 +89,4 @@ public bool TryGatherData(out InputAnalytics.IInputAnalyticData data, out Except new InputAnalytics.InputAnalyticInfo(kEventName, kMaxEventsPerHour, kMaxNumberOfElements); } } -#endif +#endif // UNITY_EDITOR diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/PlayerInputEditorAnalytic.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/PlayerInputEditorAnalytic.cs index 4520d2eb61..9a821b7f51 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/PlayerInputEditorAnalytic.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/PlayerInputEditorAnalytic.cs @@ -26,7 +26,7 @@ public PlayerInputEditorAnalytic(UnityEditor.Editor editor) public InputAnalytics.InputAnalyticInfo info => new InputAnalytics.InputAnalyticInfo(kEventName, kMaxEventsPerHour, kMaxNumberOfElements); -#if UNITY_EDITOR && UNITY_2023_2_OR_NEWER +#if UNITY_2023_2_OR_NEWER public bool TryGatherData(out UnityEngine.Analytics.IAnalytic.IData data, out Exception error) #else public bool TryGatherData(out InputAnalytics.IInputAnalyticData data, out Exception error) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/PlayerInputManagerEditorAnalytic.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/PlayerInputManagerEditorAnalytic.cs index 77656d2f02..782152fc76 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/PlayerInputManagerEditorAnalytic.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/PlayerInputManagerEditorAnalytic.cs @@ -23,7 +23,7 @@ public PlayerInputManagerEditorAnalytic(UnityEditor.Editor editor) m_Editor = editor; } -#if UNITY_EDITOR && UNITY_2023_2_OR_NEWER +#if UNITY_2023_2_OR_NEWER public bool TryGatherData(out UnityEngine.Analytics.IAnalytic.IData data, out Exception error) #else public bool TryGatherData(out InputAnalytics.IInputAnalyticData data, out Exception error) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/VirtualMouseInputEditorAnalytic.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/VirtualMouseInputEditorAnalytic.cs index a3c6c8e13e..6f1ab38610 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/VirtualMouseInputEditorAnalytic.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/VirtualMouseInputEditorAnalytic.cs @@ -72,7 +72,7 @@ public VirtualMouseInputEditorAnalytic(UnityEditor.Editor editor) m_Editor = editor; } -#if UNITY_EDITOR && UNITY_2023_2_OR_NEWER +#if UNITY_2023_2_OR_NEWER public bool TryGatherData(out UnityEngine.Analytics.IAnalytic.IData data, out Exception error) #else public bool TryGatherData(out InputAnalytics.IInputAnalyticData data, out Exception error) diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs index da1f8ad175..629f94beb8 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs @@ -91,10 +91,16 @@ private void Start() if (m_PointerDownAction == null) m_PointerDownAction = new InputAction(); + #if UNITY_EDITOR + InputExitPlayModeAnalytic.suppress = true; + #endif m_PointerDownAction.AddBinding("/leftButton"); m_PointerDownAction.AddBinding("/tip"); m_PointerDownAction.AddBinding("/touch*/press"); m_PointerDownAction.AddBinding("/trigger"); + #if UNITY_EDITOR + InputExitPlayModeAnalytic.suppress = false; + #endif } if (m_PointerMoveAction == null || m_PointerMoveAction.bindings.Count == 0) @@ -102,9 +108,15 @@ private void Start() if (m_PointerMoveAction == null) m_PointerMoveAction = new InputAction(); + #if UNITY_EDITOR + InputExitPlayModeAnalytic.suppress = true; + #endif m_PointerMoveAction.AddBinding("/position"); m_PointerMoveAction.AddBinding("/position"); m_PointerMoveAction.AddBinding("/touch*/position"); + #if UNITY_EDITOR + InputExitPlayModeAnalytic.suppress = false; + #endif } m_PointerDownAction.started += OnPointerDown; diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs index ab14e41722..59b92283b5 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/XR/TrackedPoseDriver.cs @@ -265,8 +265,7 @@ void BindPosition() if (m_PositionInput.reference == null) { - action.Rename($"{gameObject.name} - TPD - Position"); - action.Enable(); + RenameAndEnable(action, $"{gameObject.name} - TPD - Position"); } } @@ -285,8 +284,7 @@ void BindRotation() if (m_RotationInput.reference == null) { - action.Rename($"{gameObject.name} - TPD - Rotation"); - action.Enable(); + RenameAndEnable(action, $"{gameObject.name} - TPD - Rotation"); } } @@ -305,11 +303,22 @@ void BindTrackingState() if (m_TrackingStateInput.reference == null) { - action.Rename($"{gameObject.name} - TPD - Tracking State"); - action.Enable(); + RenameAndEnable(action, $"{gameObject.name} - TPD - Tracking State"); } } + private void RenameAndEnable(InputAction action, string name) + { +#if UNITY_EDITOR + Editor.InputExitPlayModeAnalytic.suppress = true; +#endif + action.Rename(name); +#if UNITY_EDITOR + Editor.InputExitPlayModeAnalytic.suppress = false; +#endif + action.Enable(); + } + void UnbindPosition() { if (!m_PositionBound)