From 054997ceb3a1f6bd892ec421fb740f63543e2487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ha=CC=8Akan=20Sidenvall?= Date: Tue, 6 May 2025 13:37:14 +0200 Subject: [PATCH 1/6] Removed uielements package dependency from package.json --- Packages/com.unity.inputsystem/package.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Packages/com.unity.inputsystem/package.json b/Packages/com.unity.inputsystem/package.json index e83319f177..d8bdccc6ab 100755 --- a/Packages/com.unity.inputsystem/package.json +++ b/Packages/com.unity.inputsystem/package.json @@ -13,8 +13,5 @@ "touch", "vr", "xr" - ], - "dependencies" : { - "com.unity.modules.uielements": "1.0.0" - } + ] } From 61c2ac685c3c2df930ea22cc18247c8ed24c43ae Mon Sep 17 00:00:00 2001 From: leonardo Date: Fri, 9 May 2025 13:12:53 +0200 Subject: [PATCH 2/6] WIP: moving editor related things into its own assembly --- .../Actions/Composites/AxisComposite.cs | 44 +---------- .../Actions/Composites/Vector2Composite.cs | 41 ---------- .../Actions/Composites/Vector3Composite.cs | 41 ---------- .../Actions/Interactions/HoldInteraction.cs | 45 +---------- .../Interactions/MultiTapInteraction.cs | 72 +----------------- .../Actions/Interactions/PressInteraction.cs | 67 +---------------- .../Interactions/SlowTapInteraction.cs | 45 +---------- .../Actions/Interactions/TapInteraction.cs | 45 +---------- .../Processors/AxisDeadzoneProcessor.cs | 44 ----------- .../Processors/StickDeadzoneProcessor.cs | 44 ----------- .../InputSystem/Editor/Actions.meta | 8 ++ .../Editor/Actions/AxisCompositeEditor.cs | 45 +++++++++++ .../Actions/AxisCompositeEditor.cs.meta | 2 + .../Editor/Actions/Interactions.meta | 8 ++ .../Interactions/HoldInteractionEditor.cs | 48 ++++++++++++ .../HoldInteractionEditor.cs.meta | 2 + .../Interactions/MultiTapInteractionEditor.cs | 75 +++++++++++++++++++ .../MultiTapInteractionEditor.cs.meta | 2 + .../Interactions/PressInteractionEditor.cs | 70 +++++++++++++++++ .../PressInteractionEditor.cs.meta | 2 + .../Interactions/SlowTapInteractionEditor.cs | 47 ++++++++++++ .../SlowTapInteractionEditor.cs.meta | 2 + .../Interactions/TapInteractionEditor.cs | 47 ++++++++++++ .../Interactions/TapInteractionEditor.cs.meta | 2 + .../Editor/Actions/Vector2CompositeEditor.cs | 44 +++++++++++ .../Actions/Vector2CompositeEditor.cs.meta | 2 + .../Editor/Actions/Vector3CompositeEditor.cs | 45 +++++++++++ .../Actions/Vector3CompositeEditor.cs.meta | 2 + .../InputSystem/Editor/Controls.meta | 8 ++ .../Editor/Controls/Processors.meta | 8 ++ .../Processors/AxisDeadzoneProcessorEditor.cs | 48 ++++++++++++ .../AxisDeadzoneProcessorEditor.cs.meta | 2 + .../StickDeadzoneProcessorEditor.cs | 49 ++++++++++++ .../StickDeadzoneProcessorEditor.cs.meta | 2 + .../InputSystem/Editor/Plugins.meta | 8 ++ .../Editor/Plugins/EnhancedTouch.meta | 8 ++ .../EnhancedTouch/TouchSimulationEditor.cs | 49 ++++++++++++ .../TouchSimulationEditor.cs.meta | 2 + .../InputSystem/Editor/Plugins/HID.meta | 8 ++ .../Plugins/HID/HIDDescriptorWindow.cs | 0 .../Plugins/HID/HIDDescriptorWindow.cs.meta | 0 .../Plugins}/InputSettingsiOSProvider.cs | 2 +- .../Plugins}/InputSettingsiOSProvider.cs.meta | 0 .../Editor/Plugins/PlayerInput.meta | 8 ++ .../PlayerInput/PlayerInputManagerEditor.cs | 2 +- .../PlayerInputManagerEditor.cs.meta | 0 .../Plugins}/PlayerInputEditor.cs | 2 +- .../Plugins}/PlayerInputEditor.cs.meta | 0 .../Editor/UnityEditor.InputSystem.asmdef | 18 +++++ .../UnityEditor.InputSystem.asmdef.meta | 7 ++ .../Plugins/EnhancedTouch/TouchSimulation.cs | 46 ------------ 51 files changed, 688 insertions(+), 530 deletions(-) create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/AxisCompositeEditor.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/AxisCompositeEditor.cs.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/HoldInteractionEditor.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/HoldInteractionEditor.cs.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/MultiTapInteractionEditor.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/MultiTapInteractionEditor.cs.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/PressInteractionEditor.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/PressInteractionEditor.cs.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/SlowTapInteractionEditor.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/SlowTapInteractionEditor.cs.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/TapInteractionEditor.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/TapInteractionEditor.cs.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector2CompositeEditor.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector2CompositeEditor.cs.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector3CompositeEditor.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector3CompositeEditor.cs.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Controls.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/AxisDeadzoneProcessorEditor.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/AxisDeadzoneProcessorEditor.cs.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/StickDeadzoneProcessorEditor.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/StickDeadzoneProcessorEditor.cs.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/EnhancedTouch.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/EnhancedTouch/TouchSimulationEditor.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/EnhancedTouch/TouchSimulationEditor.cs.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/HID.meta rename Packages/com.unity.inputsystem/InputSystem/{ => Editor}/Plugins/HID/HIDDescriptorWindow.cs (100%) rename Packages/com.unity.inputsystem/InputSystem/{ => Editor}/Plugins/HID/HIDDescriptorWindow.cs.meta (100%) rename Packages/com.unity.inputsystem/InputSystem/{Plugins/iOS => Editor/Plugins}/InputSettingsiOSProvider.cs (97%) rename Packages/com.unity.inputsystem/InputSystem/{Plugins/iOS => Editor/Plugins}/InputSettingsiOSProvider.cs.meta (100%) create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInput.meta rename Packages/com.unity.inputsystem/InputSystem/{ => Editor}/Plugins/PlayerInput/PlayerInputManagerEditor.cs (99%) rename Packages/com.unity.inputsystem/InputSystem/{ => Editor}/Plugins/PlayerInput/PlayerInputManagerEditor.cs.meta (100%) rename Packages/com.unity.inputsystem/InputSystem/{Plugins/PlayerInput => Editor/Plugins}/PlayerInputEditor.cs (99%) rename Packages/com.unity.inputsystem/InputSystem/{Plugins/PlayerInput => Editor/Plugins}/PlayerInputEditor.cs.meta (100%) create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/UnityEditor.InputSystem.asmdef create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/UnityEditor.InputSystem.asmdef.meta diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/AxisComposite.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/AxisComposite.cs index 48ae2a7c0e..9615cba078 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/AxisComposite.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/AxisComposite.cs @@ -3,12 +3,7 @@ using UnityEngine.InputSystem.Processors; using UnityEngine.InputSystem.Utilities; -#if UNITY_EDITOR -using System; -using UnityEditor; -using UnityEngine.InputSystem.Editor; -using UnityEngine.UIElements; -#endif + namespace UnityEngine.InputSystem.Composites { @@ -209,40 +204,5 @@ public enum WhichSideWins } } - #if UNITY_EDITOR - internal class AxisCompositeEditor : InputParameterEditor - { - private GUIContent m_WhichAxisWinsLabel = new GUIContent("Which Side Wins", - "Determine which axis 'wins' if both are actuated at the same time. " - + "If 'Neither' is selected, the result is 0 (or, more precisely, " - + "the midpoint between minValue and maxValue)."); - - public override void OnGUI() - { -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; -#endif - target.whichSideWins = (AxisComposite.WhichSideWins)EditorGUILayout.EnumPopup(m_WhichAxisWinsLabel, target.whichSideWins); - } - -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) - { - var modeField = new EnumField(m_WhichAxisWinsLabel.text, target.whichSideWins) - { - tooltip = m_WhichAxisWinsLabel.tooltip - }; - - modeField.RegisterValueChangedCallback(evt => - { - target.whichSideWins = (AxisComposite.WhichSideWins)evt.newValue; - onChangedCallback(); - }); - - root.Add(modeField); - } - -#endif - } - #endif + } diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/Vector2Composite.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/Vector2Composite.cs index 2f970dda8b..4b8094d95f 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/Vector2Composite.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/Vector2Composite.cs @@ -4,11 +4,6 @@ using UnityEngine.InputSystem.Layouts; using UnityEngine.InputSystem.Utilities; -#if UNITY_EDITOR -using UnityEditor; -using UnityEngine.InputSystem.Editor; -using UnityEngine.UIElements; -#endif ////TODO: add support for ramp up/down @@ -189,40 +184,4 @@ public enum Mode } } - #if UNITY_EDITOR - internal class Vector2CompositeEditor : InputParameterEditor - { - private GUIContent m_ModeLabel = new GUIContent("Mode", - "How to synthesize a Vector2 from the inputs. Digital " - + "treats part bindings as buttons (on/off) whereas Analog preserves " - + "floating-point magnitudes as read from controls."); - - public override void OnGUI() - { -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; -#endif - target.mode = (Vector2Composite.Mode)EditorGUILayout.EnumPopup(m_ModeLabel, target.mode); - } - -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) - { - var modeField = new EnumField(m_ModeLabel.text, target.mode) - { - tooltip = m_ModeLabel.tooltip - }; - - modeField.RegisterValueChangedCallback(evt => - { - target.mode = (Vector2Composite.Mode)evt.newValue; - onChangedCallback(); - }); - - root.Add(modeField); - } - -#endif - } - #endif } diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/Vector3Composite.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/Vector3Composite.cs index d9a0e510c4..93867ff464 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/Vector3Composite.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/Composites/Vector3Composite.cs @@ -3,11 +3,6 @@ using UnityEngine.InputSystem.Layouts; using UnityEngine.InputSystem.Utilities; -#if UNITY_EDITOR -using UnityEditor; -using UnityEngine.InputSystem.Editor; -using UnityEngine.UIElements; -#endif namespace UnityEngine.InputSystem.Composites { @@ -169,40 +164,4 @@ public enum Mode } } - #if UNITY_EDITOR - internal class Vector3CompositeEditor : InputParameterEditor - { - private GUIContent m_ModeLabel = new GUIContent("Mode", - "How to synthesize a Vector3 from the inputs. Digital " - + "treats part bindings as buttons (on/off) whereas Analog preserves " - + "floating-point magnitudes as read from controls."); - - public override void OnGUI() - { -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; -#endif - target.mode = (Vector3Composite.Mode)EditorGUILayout.EnumPopup(m_ModeLabel, target.mode); - } - -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) - { - var modeField = new EnumField(m_ModeLabel.text, target.mode) - { - tooltip = m_ModeLabel.tooltip - }; - - modeField.RegisterValueChangedCallback(evt => - { - target.mode = (Vector3Composite.Mode)evt.newValue; - onChangedCallback(); - }); - - root.Add(modeField); - } - -#endif - } - #endif } diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/HoldInteraction.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/HoldInteraction.cs index 79e057da25..37f03fc9a0 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/HoldInteraction.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/HoldInteraction.cs @@ -2,10 +2,7 @@ using System.ComponentModel; using UnityEngine.InputSystem.Controls; using UnityEngine.Scripting; -#if UNITY_EDITOR -using UnityEngine.InputSystem.Editor; -using UnityEngine.UIElements; -#endif + namespace UnityEngine.InputSystem.Interactions { @@ -104,44 +101,4 @@ public void Reset() } } - #if UNITY_EDITOR - /// - /// UI that is displayed when editing in the editor. - /// - internal class HoldInteractionEditor : InputParameterEditor - { - protected override void OnEnable() - { - m_PressPointSetting.Initialize("Press Point", - "Float value that an axis control has to cross for it to be considered pressed.", - "Default Button Press Point", - () => target.pressPoint, v => target.pressPoint = v, () => ButtonControl.s_GlobalDefaultButtonPressPoint); - m_DurationSetting.Initialize("Hold Time", - "Time (in seconds) that a control has to be held in order for it to register as a hold.", - "Default Hold Time", - () => target.duration, x => target.duration = x, () => InputSystem.settings.defaultHoldTime); - } - - public override void OnGUI() - { -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; -#endif - m_PressPointSetting.OnGUI(); - m_DurationSetting.OnGUI(); - } - -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) - { - m_PressPointSetting.OnDrawVisualElements(root, onChangedCallback); - m_DurationSetting.OnDrawVisualElements(root, onChangedCallback); - } - -#endif - - private CustomOrDefaultSetting m_PressPointSetting; - private CustomOrDefaultSetting m_DurationSetting; - } - #endif } diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/MultiTapInteraction.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/MultiTapInteraction.cs index 35768ca1b5..c5fb6db140 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/MultiTapInteraction.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/MultiTapInteraction.cs @@ -1,12 +1,7 @@ using System; using UnityEngine.InputSystem.Controls; using UnityEngine.Scripting; -#if UNITY_EDITOR -using UnityEditor; -using UnityEngine.InputSystem.Editor; -using UnityEngine.UIElements; -using UnityEditor.UIElements; -#endif + ////TODO: add ability to respond to any of the taps in the sequence (e.g. one response for single tap, another for double tap) @@ -169,69 +164,4 @@ private enum TapPhase } } - #if UNITY_EDITOR - /// - /// UI that is displayed when editing in the editor. - /// - internal class MultiTapInteractionEditor : InputParameterEditor - { - protected override void OnEnable() - { - m_TapTimeSetting.Initialize("Max Tap Duration", - "Time (in seconds) within with a control has to be released again for it to register as a tap. If the control is held " - + "for longer than this time, the tap is canceled.", - "Default Tap Time", - () => target.tapTime, x => target.tapTime = x, () => InputSystem.settings.defaultTapTime); - m_TapDelaySetting.Initialize("Max Tap Spacing", - "The maximum delay (in seconds) allowed between each tap. If this time is exceeded, the multi-tap is canceled.", - "Default Tap Spacing", - () => target.tapDelay, x => target.tapDelay = x, () => InputSystem.settings.multiTapDelayTime); - m_PressPointSetting.Initialize("Press Point", - "The amount of actuation a control requires before being considered pressed. If not set, default to " - + "'Default Button Press Point' in the global input settings.", - "Default Button Press Point", - () => target.pressPoint, v => target.pressPoint = v, - () => InputSystem.settings.defaultButtonPressPoint); - } - - public override void OnGUI() - { -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; -#endif - target.tapCount = EditorGUILayout.IntField(m_TapCountLabel, target.tapCount); - m_TapDelaySetting.OnGUI(); - m_TapTimeSetting.OnGUI(); - m_PressPointSetting.OnGUI(); - } - -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) - { - var tapCountField = new IntegerField(m_TapCountLabel.text) - { - value = target.tapCount, - tooltip = m_TapCountLabel.tooltip - }; - tapCountField.RegisterValueChangedCallback(evt => - { - target.tapCount = evt.newValue; - onChangedCallback?.Invoke(); - }); - root.Add(tapCountField); - - m_TapDelaySetting.OnDrawVisualElements(root, onChangedCallback); - m_TapTimeSetting.OnDrawVisualElements(root, onChangedCallback); - m_PressPointSetting.OnDrawVisualElements(root, onChangedCallback); - } - -#endif - - private readonly GUIContent m_TapCountLabel = new GUIContent("Tap Count", "How many taps need to be performed in succession. Two means double-tap, three means triple-tap, and so on."); - - private CustomOrDefaultSetting m_PressPointSetting; - private CustomOrDefaultSetting m_TapTimeSetting; - private CustomOrDefaultSetting m_TapDelaySetting; - } - #endif } diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/PressInteraction.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/PressInteraction.cs index 33cdb0bc79..7616751deb 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/PressInteraction.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/PressInteraction.cs @@ -2,12 +2,7 @@ using System.ComponentModel; using UnityEngine.InputSystem.Controls; using UnityEngine.Scripting; -#if UNITY_EDITOR -using UnityEditor; -using UnityEngine.InputSystem.Editor; -using UnityEngine.UIElements; -using UnityEditor.UIElements; -#endif + ////TODO: protect against the control *hovering* around the press point; this should not fire the press repeatedly; probably need a zone around the press point ////TODO: also, for analog controls, we probably want a deadzone that gives just a tiny little buffer at the low end before the action starts @@ -194,64 +189,4 @@ public enum PressBehavior PressAndRelease = 2, } - #if UNITY_EDITOR - /// - /// UI that is displayed when editing in the editor. - /// - // ReSharper disable once UnusedMember.Global - internal class PressInteractionEditor : InputParameterEditor - { - protected override void OnEnable() - { - m_PressPointSetting.Initialize("Press Point", - "The amount of actuation a control requires before being considered pressed. If not set, default to " - + "'Default Button Press Point' in the global input settings.", - "Default Button Press Point", - () => target.pressPoint, v => target.pressPoint = v, - () => InputSystem.settings.defaultButtonPressPoint); - } - - public override void OnGUI() - { -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; -#endif - EditorGUILayout.HelpBox(s_HelpBoxText); - target.behavior = (PressBehavior)EditorGUILayout.EnumPopup(s_PressBehaviorLabel, target.behavior); - m_PressPointSetting.OnGUI(); - } - -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) - { - root.Add(new HelpBox(s_HelpBoxText.text, HelpBoxMessageType.None)); - - var behaviourDropdown = new EnumField(s_PressBehaviorLabel.text, target.behavior) - { - tooltip = s_PressBehaviorLabel.tooltip - }; - behaviourDropdown.RegisterValueChangedCallback(evt => - { - target.behavior = (PressBehavior)evt.newValue; - onChangedCallback?.Invoke(); - }); - root.Add(behaviourDropdown); - - m_PressPointSetting.OnDrawVisualElements(root, onChangedCallback); - } - -#endif - - private CustomOrDefaultSetting m_PressPointSetting; - - private static readonly GUIContent s_HelpBoxText = EditorGUIUtility.TrTextContent("Note that the 'Press' interaction is only " - + "necessary when wanting to customize button press behavior. For default press behavior, simply set the action type to 'Button' " - + "and use the action without interactions added to it."); - - private static readonly GUIContent s_PressBehaviorLabel = EditorGUIUtility.TrTextContent("Trigger Behavior", - "Determines how button presses trigger the action. By default (PressOnly), the action is performed on press. " - + "With ReleaseOnly, the action is performed on release. With PressAndRelease, the action is performed on press and " - + "canceled on release."); - } - #endif } diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/SlowTapInteraction.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/SlowTapInteraction.cs index 5309ab7a5d..3675b7b5ab 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/SlowTapInteraction.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/SlowTapInteraction.cs @@ -2,10 +2,7 @@ using System.ComponentModel; using UnityEngine.InputSystem.Controls; using UnityEngine.Scripting; -#if UNITY_EDITOR -using UnityEngine.InputSystem.Editor; -using UnityEngine.UIElements; -#endif + ////REVIEW: this is confusing when considered next to HoldInteraction; also it's confusingly named @@ -68,44 +65,4 @@ public void Reset() } } - #if UNITY_EDITOR - internal class SlowTapInteractionEditor : InputParameterEditor - { - protected override void OnEnable() - { - m_DurationSetting.Initialize("Min Tap Duration", - "Minimum time (in seconds) that a control has to be held for it to register as a slow tap. If the control is released " - + "before this time, the slow tap is canceled.", - "Default Slow Tap Time", - () => target.duration, x => target.duration = x, () => InputSystem.settings.defaultSlowTapTime); - m_PressPointSetting.Initialize("Press Point", - "The amount of actuation a control requires before being considered pressed. If not set, default to " - + "'Default Button Press Point' in the global input settings.", - "Default Button Press Point", - () => target.pressPoint, v => target.pressPoint = v, - () => InputSystem.settings.defaultButtonPressPoint); - } - - public override void OnGUI() - { -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; -#endif - m_DurationSetting.OnGUI(); - m_PressPointSetting.OnGUI(); - } - -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) - { - m_DurationSetting.OnDrawVisualElements(root, onChangedCallback); - m_PressPointSetting.OnDrawVisualElements(root, onChangedCallback); - } - -#endif - - private CustomOrDefaultSetting m_DurationSetting; - private CustomOrDefaultSetting m_PressPointSetting; - } - #endif } diff --git a/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/TapInteraction.cs b/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/TapInteraction.cs index 510b1caef2..b6cb17b0a0 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/TapInteraction.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/TapInteraction.cs @@ -2,10 +2,7 @@ using System.ComponentModel; using UnityEngine.InputSystem.Controls; using UnityEngine.Scripting; -#if UNITY_EDITOR -using UnityEngine.InputSystem.Editor; -using UnityEngine.UIElements; -#endif + namespace UnityEngine.InputSystem.Interactions { @@ -94,44 +91,4 @@ public void Reset() } } - #if UNITY_EDITOR - internal class TapInteractionEditor : InputParameterEditor - { - protected override void OnEnable() - { - m_DurationSetting.Initialize("Max Tap Duration", - "Time (in seconds) within with a control has to be released again for it to register as a tap. If the control is held " - + "for longer than this time, the tap is canceled.", - "Default Tap Time", - () => target.duration, x => target.duration = x, () => InputSystem.settings.defaultTapTime); - m_PressPointSetting.Initialize("Press Point", - "The amount of actuation a control requires before being considered pressed. If not set, default to " - + "'Default Button Press Point' in the global input settings.", - "Default Button Press Point", - () => target.pressPoint, v => target.pressPoint = v, - () => InputSystem.settings.defaultButtonPressPoint); - } - - public override void OnGUI() - { -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; -#endif - m_DurationSetting.OnGUI(); - m_PressPointSetting.OnGUI(); - } - -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) - { - m_DurationSetting.OnDrawVisualElements(root, onChangedCallback); - m_PressPointSetting.OnDrawVisualElements(root, onChangedCallback); - } - -#endif - - private CustomOrDefaultSetting m_DurationSetting; - private CustomOrDefaultSetting m_PressPointSetting; - } - #endif } diff --git a/Packages/com.unity.inputsystem/InputSystem/Controls/Processors/AxisDeadzoneProcessor.cs b/Packages/com.unity.inputsystem/InputSystem/Controls/Processors/AxisDeadzoneProcessor.cs index d9c33718a4..e3aceb4b62 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Controls/Processors/AxisDeadzoneProcessor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Controls/Processors/AxisDeadzoneProcessor.cs @@ -1,11 +1,6 @@ using System; using UnityEngine.Scripting; -#if UNITY_EDITOR -using UnityEngine.InputSystem.Editor; -using UnityEngine.UIElements; -#endif - namespace UnityEngine.InputSystem.Processors { /// @@ -74,43 +69,4 @@ public override string ToString() } } - #if UNITY_EDITOR - internal class AxisDeadzoneProcessorEditor : InputParameterEditor - { - protected override void OnEnable() - { - m_MinSetting.Initialize("Min", - "Value below which input values will be clamped. After clamping, values will be renormalized to [0..1] between min and max.", - "Default Deadzone Min", - () => target.min, v => target.min = v, - () => InputSystem.settings.defaultDeadzoneMin); - m_MaxSetting.Initialize("Max", - "Value above which input values will be clamped. After clamping, values will be renormalized to [0..1] between min and max.", - "Default Deadzone Max", - () => target.max, v => target.max = v, - () => InputSystem.settings.defaultDeadzoneMax); - } - - public override void OnGUI() - { -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; -#endif - m_MinSetting.OnGUI(); - m_MaxSetting.OnGUI(); - } - -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) - { - m_MinSetting.OnDrawVisualElements(root, onChangedCallback); - m_MaxSetting.OnDrawVisualElements(root, onChangedCallback); - } - -#endif - - private CustomOrDefaultSetting m_MinSetting; - private CustomOrDefaultSetting m_MaxSetting; - } - #endif } diff --git a/Packages/com.unity.inputsystem/InputSystem/Controls/Processors/StickDeadzoneProcessor.cs b/Packages/com.unity.inputsystem/InputSystem/Controls/Processors/StickDeadzoneProcessor.cs index b0115b977b..611c72aa5d 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Controls/Processors/StickDeadzoneProcessor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Controls/Processors/StickDeadzoneProcessor.cs @@ -1,11 +1,6 @@ using System; using UnityEngine.Scripting; -#if UNITY_EDITOR -using UnityEngine.InputSystem.Editor; -using UnityEngine.UIElements; -#endif - ////REVIEW: rename to RadialDeadzone ////TODO: add different deadzone shapes and/or option to min/max X and Y separately @@ -63,43 +58,4 @@ public override string ToString() } } - #if UNITY_EDITOR - internal class StickDeadzoneProcessorEditor : InputParameterEditor - { - protected override void OnEnable() - { - m_MinSetting.Initialize("Min", - "Vector length below which input values will be clamped. After clamping, vector lengths will be renormalized to [0..1] between min and max.", - "Default Deadzone Min", - () => target.min, v => target.min = v, - () => InputSystem.settings.defaultDeadzoneMin); - m_MaxSetting.Initialize("Max", - "Vector length above which input values will be clamped. After clamping, vector lengths will be renormalized to [0..1] between min and max.", - "Default Deadzone Max", - () => target.max, v => target.max = v, - () => InputSystem.settings.defaultDeadzoneMax); - } - - public override void OnGUI() - { -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; -#endif - m_MinSetting.OnGUI(); - m_MaxSetting.OnGUI(); - } - -#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) - { - m_MinSetting.OnDrawVisualElements(root, onChangedCallback); - m_MaxSetting.OnDrawVisualElements(root, onChangedCallback); - } - -#endif - - private CustomOrDefaultSetting m_MinSetting; - private CustomOrDefaultSetting m_MaxSetting; - } - #endif } diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions.meta new file mode 100644 index 0000000000..6fb384287c --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 51c96b8e65b5a46b28c06e3fbc751c97 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/AxisCompositeEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/AxisCompositeEditor.cs new file mode 100644 index 0000000000..33c427f238 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/AxisCompositeEditor.cs @@ -0,0 +1,45 @@ +#if UNITY_EDITOR +using System; +using UnityEditor; +using UnityEngine.InputSystem.Editor; +using UnityEngine.UIElements; +#endif + +namespace UnityEditor.InputSystem.Composites { +#if UNITY_EDITOR + internal class AxisCompositeEditor : InputParameterEditor + { + private GUIContent m_WhichAxisWinsLabel = new GUIContent("Which Side Wins", + "Determine which axis 'wins' if both are actuated at the same time. " + + "If 'Neither' is selected, the result is 0 (or, more precisely, " + + "the midpoint between minValue and maxValue)."); + + public override void OnGUI() + { +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + if (!InputSystem.settings.useIMGUIEditorForAssets) return; +#endif + target.whichSideWins = (AxisComposite.WhichSideWins)EditorGUILayout.EnumPopup(m_WhichAxisWinsLabel, target.whichSideWins); + } + +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) + { + var modeField = new EnumField(m_WhichAxisWinsLabel.text, target.whichSideWins) + { + tooltip = m_WhichAxisWinsLabel.tooltip + }; + + modeField.RegisterValueChangedCallback(evt => + { + target.whichSideWins = (AxisComposite.WhichSideWins)evt.newValue; + onChangedCallback(); + }); + + root.Add(modeField); + } + +#endif + } + #endif +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/AxisCompositeEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/AxisCompositeEditor.cs.meta new file mode 100644 index 0000000000..2551df2c89 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/AxisCompositeEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: f04048c85eab54bcc9c4cba980634c7c \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions.meta new file mode 100644 index 0000000000..865b6a58b4 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 79f4019b5557b4b8a87a46a5869d9666 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/HoldInteractionEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/HoldInteractionEditor.cs new file mode 100644 index 0000000000..286f543215 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/HoldInteractionEditor.cs @@ -0,0 +1,48 @@ +#if UNITY_EDITOR +using UnityEngine.InputSystem.Editor; +using UnityEngine.UIElements; +#endif + +namespace UnityEditor.InputSystem.Interactions +{ + #if UNITY_EDITOR + /// + /// UI that is displayed when editing in the editor. + /// + internal class HoldInteractionEditor : InputParameterEditor + { + protected override void OnEnable() + { + m_PressPointSetting.Initialize("Press Point", + "Float value that an axis control has to cross for it to be considered pressed.", + "Default Button Press Point", + () => target.pressPoint, v => target.pressPoint = v, () => ButtonControl.s_GlobalDefaultButtonPressPoint); + m_DurationSetting.Initialize("Hold Time", + "Time (in seconds) that a control has to be held in order for it to register as a hold.", + "Default Hold Time", + () => target.duration, x => target.duration = x, () => InputSystem.settings.defaultHoldTime); + } + + public override void OnGUI() + { +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + if (!InputSystem.settings.useIMGUIEditorForAssets) return; +#endif + m_PressPointSetting.OnGUI(); + m_DurationSetting.OnGUI(); + } + +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) + { + m_PressPointSetting.OnDrawVisualElements(root, onChangedCallback); + m_DurationSetting.OnDrawVisualElements(root, onChangedCallback); + } + +#endif + + private CustomOrDefaultSetting m_PressPointSetting; + private CustomOrDefaultSetting m_DurationSetting; + } + #endif +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/HoldInteractionEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/HoldInteractionEditor.cs.meta new file mode 100644 index 0000000000..8df8a3ad74 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/HoldInteractionEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 1813c37aa62dd457f8a68e4884883b46 \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/MultiTapInteractionEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/MultiTapInteractionEditor.cs new file mode 100644 index 0000000000..bd480bafd5 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/MultiTapInteractionEditor.cs @@ -0,0 +1,75 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine.InputSystem.Editor; +using UnityEngine.UIElements; +using UnityEditor.UIElements; +#endif + +namespace UnityEditor.InputSystem.Interactions { + + #if UNITY_EDITOR + /// + /// UI that is displayed when editing in the editor. + /// + internal class MultiTapInteractionEditor : InputParameterEditor + { + protected override void OnEnable() + { + m_TapTimeSetting.Initialize("Max Tap Duration", + "Time (in seconds) within with a control has to be released again for it to register as a tap. If the control is held " + + "for longer than this time, the tap is canceled.", + "Default Tap Time", + () => target.tapTime, x => target.tapTime = x, () => InputSystem.settings.defaultTapTime); + m_TapDelaySetting.Initialize("Max Tap Spacing", + "The maximum delay (in seconds) allowed between each tap. If this time is exceeded, the multi-tap is canceled.", + "Default Tap Spacing", + () => target.tapDelay, x => target.tapDelay = x, () => InputSystem.settings.multiTapDelayTime); + m_PressPointSetting.Initialize("Press Point", + "The amount of actuation a control requires before being considered pressed. If not set, default to " + + "'Default Button Press Point' in the global input settings.", + "Default Button Press Point", + () => target.pressPoint, v => target.pressPoint = v, + () => InputSystem.settings.defaultButtonPressPoint); + } + + public override void OnGUI() + { +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + if (!InputSystem.settings.useIMGUIEditorForAssets) return; +#endif + target.tapCount = EditorGUILayout.IntField(m_TapCountLabel, target.tapCount); + m_TapDelaySetting.OnGUI(); + m_TapTimeSetting.OnGUI(); + m_PressPointSetting.OnGUI(); + } + +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) + { + var tapCountField = new IntegerField(m_TapCountLabel.text) + { + value = target.tapCount, + tooltip = m_TapCountLabel.tooltip + }; + tapCountField.RegisterValueChangedCallback(evt => + { + target.tapCount = evt.newValue; + onChangedCallback?.Invoke(); + }); + root.Add(tapCountField); + + m_TapDelaySetting.OnDrawVisualElements(root, onChangedCallback); + m_TapTimeSetting.OnDrawVisualElements(root, onChangedCallback); + m_PressPointSetting.OnDrawVisualElements(root, onChangedCallback); + } + +#endif + + private readonly GUIContent m_TapCountLabel = new GUIContent("Tap Count", "How many taps need to be performed in succession. Two means double-tap, three means triple-tap, and so on."); + + private CustomOrDefaultSetting m_PressPointSetting; + private CustomOrDefaultSetting m_TapTimeSetting; + private CustomOrDefaultSetting m_TapDelaySetting; + } + #endif +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/MultiTapInteractionEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/MultiTapInteractionEditor.cs.meta new file mode 100644 index 0000000000..042b7f5f8b --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/MultiTapInteractionEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 85d8fcbf2ff9c43aeb6c2259780ee390 \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/PressInteractionEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/PressInteractionEditor.cs new file mode 100644 index 0000000000..9cb81215c2 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/PressInteractionEditor.cs @@ -0,0 +1,70 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine.InputSystem.Editor; +using UnityEngine.UIElements; +using UnityEditor.UIElements; +#endif + +namespace UnityEditor.InputSystem.Interactions { + + #if UNITY_EDITOR + /// + /// UI that is displayed when editing in the editor. + /// + // ReSharper disable once UnusedMember.Global + internal class PressInteractionEditor : InputParameterEditor + { + protected override void OnEnable() + { + m_PressPointSetting.Initialize("Press Point", + "The amount of actuation a control requires before being considered pressed. If not set, default to " + + "'Default Button Press Point' in the global input settings.", + "Default Button Press Point", + () => target.pressPoint, v => target.pressPoint = v, + () => InputSystem.settings.defaultButtonPressPoint); + } + + public override void OnGUI() + { +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + if (!InputSystem.settings.useIMGUIEditorForAssets) return; +#endif + EditorGUILayout.HelpBox(s_HelpBoxText); + target.behavior = (PressBehavior)EditorGUILayout.EnumPopup(s_PressBehaviorLabel, target.behavior); + m_PressPointSetting.OnGUI(); + } + +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) + { + root.Add(new HelpBox(s_HelpBoxText.text, HelpBoxMessageType.None)); + + var behaviourDropdown = new EnumField(s_PressBehaviorLabel.text, target.behavior) + { + tooltip = s_PressBehaviorLabel.tooltip + }; + behaviourDropdown.RegisterValueChangedCallback(evt => + { + target.behavior = (PressBehavior)evt.newValue; + onChangedCallback?.Invoke(); + }); + root.Add(behaviourDropdown); + + m_PressPointSetting.OnDrawVisualElements(root, onChangedCallback); + } + +#endif + + private CustomOrDefaultSetting m_PressPointSetting; + + private static readonly GUIContent s_HelpBoxText = EditorGUIUtility.TrTextContent("Note that the 'Press' interaction is only " + + "necessary when wanting to customize button press behavior. For default press behavior, simply set the action type to 'Button' " + + "and use the action without interactions added to it."); + + private static readonly GUIContent s_PressBehaviorLabel = EditorGUIUtility.TrTextContent("Trigger Behavior", + "Determines how button presses trigger the action. By default (PressOnly), the action is performed on press. " + + "With ReleaseOnly, the action is performed on release. With PressAndRelease, the action is performed on press and " + + "canceled on release."); + } + #endif +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/PressInteractionEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/PressInteractionEditor.cs.meta new file mode 100644 index 0000000000..5db1d36423 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/PressInteractionEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 228872d31667d4011bfcaff0a589c4a1 \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/SlowTapInteractionEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/SlowTapInteractionEditor.cs new file mode 100644 index 0000000000..6ab05f9290 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/SlowTapInteractionEditor.cs @@ -0,0 +1,47 @@ +#if UNITY_EDITOR +using UnityEngine.InputSystem.Editor; +using UnityEngine.UIElements; +#endif + +namespace UnityEditor.InputSystem.Interactions { + #if UNITY_EDITOR + internal class SlowTapInteractionEditor : InputParameterEditor + { + protected override void OnEnable() + { + m_DurationSetting.Initialize("Min Tap Duration", + "Minimum time (in seconds) that a control has to be held for it to register as a slow tap. If the control is released " + + "before this time, the slow tap is canceled.", + "Default Slow Tap Time", + () => target.duration, x => target.duration = x, () => InputSystem.settings.defaultSlowTapTime); + m_PressPointSetting.Initialize("Press Point", + "The amount of actuation a control requires before being considered pressed. If not set, default to " + + "'Default Button Press Point' in the global input settings.", + "Default Button Press Point", + () => target.pressPoint, v => target.pressPoint = v, + () => InputSystem.settings.defaultButtonPressPoint); + } + + public override void OnGUI() + { +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + if (!InputSystem.settings.useIMGUIEditorForAssets) return; +#endif + m_DurationSetting.OnGUI(); + m_PressPointSetting.OnGUI(); + } + +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) + { + m_DurationSetting.OnDrawVisualElements(root, onChangedCallback); + m_PressPointSetting.OnDrawVisualElements(root, onChangedCallback); + } + +#endif + + private CustomOrDefaultSetting m_DurationSetting; + private CustomOrDefaultSetting m_PressPointSetting; + } + #endif +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/SlowTapInteractionEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/SlowTapInteractionEditor.cs.meta new file mode 100644 index 0000000000..396e87cc81 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/SlowTapInteractionEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 039c745f633954ebb99500cc5f3169b6 \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/TapInteractionEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/TapInteractionEditor.cs new file mode 100644 index 0000000000..3f07fa9c7d --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/TapInteractionEditor.cs @@ -0,0 +1,47 @@ +#if UNITY_EDITOR +using UnityEngine.InputSystem.Editor; +using UnityEngine.UIElements; +#endif + +namespace UnityEditor.InputSystem.Interactions { + #if UNITY_EDITOR + internal class TapInteractionEditor : InputParameterEditor + { + protected override void OnEnable() + { + m_DurationSetting.Initialize("Max Tap Duration", + "Time (in seconds) within with a control has to be released again for it to register as a tap. If the control is held " + + "for longer than this time, the tap is canceled.", + "Default Tap Time", + () => target.duration, x => target.duration = x, () => InputSystem.settings.defaultTapTime); + m_PressPointSetting.Initialize("Press Point", + "The amount of actuation a control requires before being considered pressed. If not set, default to " + + "'Default Button Press Point' in the global input settings.", + "Default Button Press Point", + () => target.pressPoint, v => target.pressPoint = v, + () => InputSystem.settings.defaultButtonPressPoint); + } + + public override void OnGUI() + { +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + if (!InputSystem.settings.useIMGUIEditorForAssets) return; +#endif + m_DurationSetting.OnGUI(); + m_PressPointSetting.OnGUI(); + } + +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) + { + m_DurationSetting.OnDrawVisualElements(root, onChangedCallback); + m_PressPointSetting.OnDrawVisualElements(root, onChangedCallback); + } + +#endif + + private CustomOrDefaultSetting m_DurationSetting; + private CustomOrDefaultSetting m_PressPointSetting; + } + #endif +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/TapInteractionEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/TapInteractionEditor.cs.meta new file mode 100644 index 0000000000..6e5baa0123 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/TapInteractionEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ede705751310c4c47b92755caa86da69 \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector2CompositeEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector2CompositeEditor.cs new file mode 100644 index 0000000000..baad150428 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector2CompositeEditor.cs @@ -0,0 +1,44 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine.InputSystem.Editor; +using UnityEngine.UIElements; +#endif + +namespace UnityEditor.InputSystem.Composites { + #if UNITY_EDITOR + internal class Vector2CompositeEditor : InputParameterEditor + { + private GUIContent m_ModeLabel = new GUIContent("Mode", + "How to synthesize a Vector2 from the inputs. Digital " + + "treats part bindings as buttons (on/off) whereas Analog preserves " + + "floating-point magnitudes as read from controls."); + + public override void OnGUI() + { +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + if (!InputSystem.settings.useIMGUIEditorForAssets) return; +#endif + target.mode = (Vector2Composite.Mode)EditorGUILayout.EnumPopup(m_ModeLabel, target.mode); + } + +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) + { + var modeField = new EnumField(m_ModeLabel.text, target.mode) + { + tooltip = m_ModeLabel.tooltip + }; + + modeField.RegisterValueChangedCallback(evt => + { + target.mode = (Vector2Composite.Mode)evt.newValue; + onChangedCallback(); + }); + + root.Add(modeField); + } + +#endif + } + #endif +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector2CompositeEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector2CompositeEditor.cs.meta new file mode 100644 index 0000000000..bd74d4d0a6 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector2CompositeEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: bc26b75e5423c40078082d8e558222d0 \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector3CompositeEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector3CompositeEditor.cs new file mode 100644 index 0000000000..c540c98402 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector3CompositeEditor.cs @@ -0,0 +1,45 @@ + +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine.InputSystem.Editor; +using UnityEngine.UIElements; +#endif + +namespace UnityEditor.InputSystem.Composites { + #if UNITY_EDITOR + internal class Vector3CompositeEditor : InputParameterEditor + { + private GUIContent m_ModeLabel = new GUIContent("Mode", + "How to synthesize a Vector3 from the inputs. Digital " + + "treats part bindings as buttons (on/off) whereas Analog preserves " + + "floating-point magnitudes as read from controls."); + + public override void OnGUI() + { +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + if (!InputSystem.settings.useIMGUIEditorForAssets) return; +#endif + target.mode = (Vector3Composite.Mode)EditorGUILayout.EnumPopup(m_ModeLabel, target.mode); + } + +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) + { + var modeField = new EnumField(m_ModeLabel.text, target.mode) + { + tooltip = m_ModeLabel.tooltip + }; + + modeField.RegisterValueChangedCallback(evt => + { + target.mode = (Vector3Composite.Mode)evt.newValue; + onChangedCallback(); + }); + + root.Add(modeField); + } + +#endif + } + #endif +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector3CompositeEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector3CompositeEditor.cs.meta new file mode 100644 index 0000000000..42ecbaaeef --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector3CompositeEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 30d6e70def27c4f0bb92b90ed5d7431b \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Controls.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Controls.meta new file mode 100644 index 0000000000..24b3fff5bb --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Controls.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 51baa5495e14f4589bdd9593c6a72ae3 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors.meta new file mode 100644 index 0000000000..aaac5804bc --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b4690836c3a9e42f18b8d14b10b92097 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/AxisDeadzoneProcessorEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/AxisDeadzoneProcessorEditor.cs new file mode 100644 index 0000000000..3c1f7b5ede --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/AxisDeadzoneProcessorEditor.cs @@ -0,0 +1,48 @@ + +#if UNITY_EDITOR +using UnityEngine.InputSystem.Editor; +using UnityEngine.UIElements; +#endif + +namespace UnityEditor.InputSystem.Processors { + + #if UNITY_EDITOR + internal class AxisDeadzoneProcessorEditor : InputParameterEditor + { + protected override void OnEnable() + { + m_MinSetting.Initialize("Min", + "Value below which input values will be clamped. After clamping, values will be renormalized to [0..1] between min and max.", + "Default Deadzone Min", + () => target.min, v => target.min = v, + () => InputSystem.settings.defaultDeadzoneMin); + m_MaxSetting.Initialize("Max", + "Value above which input values will be clamped. After clamping, values will be renormalized to [0..1] between min and max.", + "Default Deadzone Max", + () => target.max, v => target.max = v, + () => InputSystem.settings.defaultDeadzoneMax); + } + + public override void OnGUI() + { +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + if (!InputSystem.settings.useIMGUIEditorForAssets) return; +#endif + m_MinSetting.OnGUI(); + m_MaxSetting.OnGUI(); + } + +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) + { + m_MinSetting.OnDrawVisualElements(root, onChangedCallback); + m_MaxSetting.OnDrawVisualElements(root, onChangedCallback); + } + +#endif + + private CustomOrDefaultSetting m_MinSetting; + private CustomOrDefaultSetting m_MaxSetting; + } + #endif +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/AxisDeadzoneProcessorEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/AxisDeadzoneProcessorEditor.cs.meta new file mode 100644 index 0000000000..7552a98c48 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/AxisDeadzoneProcessorEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: f99afff196aaa4c64afc7f43a7ffd427 \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/StickDeadzoneProcessorEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/StickDeadzoneProcessorEditor.cs new file mode 100644 index 0000000000..227f2cc199 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/StickDeadzoneProcessorEditor.cs @@ -0,0 +1,49 @@ + + +#if UNITY_EDITOR +using UnityEngine.InputSystem.Editor; +using UnityEngine.UIElements; +#endif + +namespace UnityEditor.InputSystem.Processors { + + #if UNITY_EDITOR + internal class StickDeadzoneProcessorEditor : InputParameterEditor + { + protected override void OnEnable() + { + m_MinSetting.Initialize("Min", + "Vector length below which input values will be clamped. After clamping, vector lengths will be renormalized to [0..1] between min and max.", + "Default Deadzone Min", + () => target.min, v => target.min = v, + () => InputSystem.settings.defaultDeadzoneMin); + m_MaxSetting.Initialize("Max", + "Vector length above which input values will be clamped. After clamping, vector lengths will be renormalized to [0..1] between min and max.", + "Default Deadzone Max", + () => target.max, v => target.max = v, + () => InputSystem.settings.defaultDeadzoneMax); + } + + public override void OnGUI() + { +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + if (!InputSystem.settings.useIMGUIEditorForAssets) return; +#endif + m_MinSetting.OnGUI(); + m_MaxSetting.OnGUI(); + } + +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + public override void OnDrawVisualElements(VisualElement root, Action onChangedCallback) + { + m_MinSetting.OnDrawVisualElements(root, onChangedCallback); + m_MaxSetting.OnDrawVisualElements(root, onChangedCallback); + } + +#endif + + private CustomOrDefaultSetting m_MinSetting; + private CustomOrDefaultSetting m_MaxSetting; + } + #endif +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/StickDeadzoneProcessorEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/StickDeadzoneProcessorEditor.cs.meta new file mode 100644 index 0000000000..492af85bf7 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/StickDeadzoneProcessorEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 59bbf7f4fa3af4e0eb0ed7eaabff05db \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins.meta new file mode 100644 index 0000000000..0394724d25 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b873975c6661d4c3a9442c4134bb5c63 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/EnhancedTouch.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/EnhancedTouch.meta new file mode 100644 index 0000000000..a07605c224 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/EnhancedTouch.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 802b0375540bb4a04be19fe17d88d659 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/EnhancedTouch/TouchSimulationEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/EnhancedTouch/TouchSimulationEditor.cs new file mode 100644 index 0000000000..25fe546389 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/EnhancedTouch/TouchSimulationEditor.cs @@ -0,0 +1,49 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine.InputSystem.Editor; +#endif + +namespace UnityEngine.InputSystem.EnhancedTouch { + + [InitializeOnLoad] + private class TouchSimulationEdtiorInitialization + { + static TouchSimulation() + { + // We're a MonoBehaviour so our cctor may get called as part of the MonoBehaviour being + // created. We don't want to trigger InputSystem initialization from there so delay-execute + // the code here. + EditorApplication.delayCall += + () => + { + InputSystem.onSettingsChange += OnSettingsChanged; + InputSystem.onBeforeUpdate += ReEnableAfterDomainReload; + }; + } + + private static void ReEnableAfterDomainReload() + { + OnSettingsChanged(); + InputSystem.onBeforeUpdate -= ReEnableAfterDomainReload; + } + + private static void OnSettingsChanged() + { + if (InputEditorUserSettings.simulateTouch) + TouchSimulation.Enable(); + else + TouchSimulation.Disable(); + } + + } + + + [CustomEditor(typeof(TouchSimulation))] + private class TouchSimulationEditor : UnityEditor.Editor + { + public void OnDisable() + { + new InputComponentEditorAnalytic(InputSystemComponent.TouchSimulation).Send(); + } + } +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/EnhancedTouch/TouchSimulationEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/EnhancedTouch/TouchSimulationEditor.cs.meta new file mode 100644 index 0000000000..2a51a256cc --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/EnhancedTouch/TouchSimulationEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 848690e04e53948a5b5ffb210a4fa64f \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/HID.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/HID.meta new file mode 100644 index 0000000000..fbae2f9e60 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/HID.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2a5747283a8db45e99cf4536241aeb9a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/HID/HIDDescriptorWindow.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/HID/HIDDescriptorWindow.cs similarity index 100% rename from Packages/com.unity.inputsystem/InputSystem/Plugins/HID/HIDDescriptorWindow.cs rename to Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/HID/HIDDescriptorWindow.cs diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/HID/HIDDescriptorWindow.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/HID/HIDDescriptorWindow.cs.meta similarity index 100% rename from Packages/com.unity.inputsystem/InputSystem/Plugins/HID/HIDDescriptorWindow.cs.meta rename to Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/HID/HIDDescriptorWindow.cs.meta diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/iOS/InputSettingsiOSProvider.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/InputSettingsiOSProvider.cs similarity index 97% rename from Packages/com.unity.inputsystem/InputSystem/Plugins/iOS/InputSettingsiOSProvider.cs rename to Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/InputSettingsiOSProvider.cs index 36eb6f92f9..159f21efed 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/iOS/InputSettingsiOSProvider.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/InputSettingsiOSProvider.cs @@ -2,7 +2,7 @@ using System; using UnityEditor; -namespace UnityEngine.InputSystem +namespace UnityEditor.InputSystem { internal class InputSettingsiOSProvider { diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/iOS/InputSettingsiOSProvider.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/InputSettingsiOSProvider.cs.meta similarity index 100% rename from Packages/com.unity.inputsystem/InputSystem/Plugins/iOS/InputSettingsiOSProvider.cs.meta rename to Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/InputSettingsiOSProvider.cs.meta diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInput.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInput.meta new file mode 100644 index 0000000000..ab0256a2fc --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInput.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3797c94c0360c4497af338652e02249a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputManagerEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInput/PlayerInputManagerEditor.cs similarity index 99% rename from Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputManagerEditor.cs rename to Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInput/PlayerInputManagerEditor.cs index 48055a7373..5555838bc1 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputManagerEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInput/PlayerInputManagerEditor.cs @@ -4,7 +4,7 @@ using UnityEditor; using UnityEngine.InputSystem.Users; -namespace UnityEngine.InputSystem.Editor +namespace UnityEditor.InputSystem.Editor { /// /// Custom inspector for . diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputManagerEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInput/PlayerInputManagerEditor.cs.meta similarity index 100% rename from Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputManagerEditor.cs.meta rename to Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInput/PlayerInputManagerEditor.cs.meta diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInputEditor.cs similarity index 99% rename from Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputEditor.cs rename to Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInputEditor.cs index f6f36f6251..a8114b1061 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInputEditor.cs @@ -15,7 +15,7 @@ ////TODO: detect if new input system isn't enabled and provide UI to enable it #pragma warning disable 0414 -namespace UnityEngine.InputSystem.Editor +namespace UnityEditor.InputSystem.Editor { /// /// A custom inspector for the component. diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInputEditor.cs.meta similarity index 100% rename from Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputEditor.cs.meta rename to Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInputEditor.cs.meta diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UnityEditor.InputSystem.asmdef b/Packages/com.unity.inputsystem/InputSystem/Editor/UnityEditor.InputSystem.asmdef new file mode 100644 index 0000000000..efdc92ba6e --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UnityEditor.InputSystem.asmdef @@ -0,0 +1,18 @@ +{ + "name": "UnityEditor.InputSystem", + "rootNamespace": "", + "references": [ + "GUID:75469ad4d38634e559750d17036d5f7c" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UnityEditor.InputSystem.asmdef.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/UnityEditor.InputSystem.asmdef.meta new file mode 100644 index 0000000000..18102de83d --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UnityEditor.InputSystem.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 43c9ed31071e54e6ab323e5e2f3bdc9c +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/EnhancedTouch/TouchSimulation.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/EnhancedTouch/TouchSimulation.cs index 108e83e5a4..d7bbc15ccd 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/EnhancedTouch/TouchSimulation.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/EnhancedTouch/TouchSimulation.cs @@ -3,10 +3,6 @@ using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.LowLevel; using UnityEngine.InputSystem.Utilities; -#if UNITY_EDITOR -using UnityEditor; -using UnityEngine.InputSystem.Editor; -#endif ////TODO: add pressure support @@ -32,9 +28,6 @@ namespace UnityEngine.InputSystem.EnhancedTouch [AddComponentMenu("Input/Debug/Touch Simulation")] [ExecuteInEditMode] [HelpURL(InputSystem.kDocUrl + "/manual/Touch.html#touch-simulation")] - #if UNITY_EDITOR - [InitializeOnLoad] - #endif public class TouchSimulation : MonoBehaviour, IInputStateChangeMonitor { public Touchscreen simulatedTouchscreen { get; private set; } @@ -341,45 +334,6 @@ private unsafe void UpdateTouch(int touchIndex, int pointerIndex, TouchPhase pha internal static TouchSimulation s_Instance; - #if UNITY_EDITOR - static TouchSimulation() - { - // We're a MonoBehaviour so our cctor may get called as part of the MonoBehaviour being - // created. We don't want to trigger InputSystem initialization from there so delay-execute - // the code here. - EditorApplication.delayCall += - () => - { - InputSystem.onSettingsChange += OnSettingsChanged; - InputSystem.onBeforeUpdate += ReEnableAfterDomainReload; - }; - } - - private static void ReEnableAfterDomainReload() - { - OnSettingsChanged(); - InputSystem.onBeforeUpdate -= ReEnableAfterDomainReload; - } - - private static void OnSettingsChanged() - { - if (InputEditorUserSettings.simulateTouch) - Enable(); - else - Disable(); - } - - [CustomEditor(typeof(TouchSimulation))] - private class TouchSimulationEditor : UnityEditor.Editor - { - public void OnDisable() - { - new InputComponentEditorAnalytic(InputSystemComponent.TouchSimulation).Send(); - } - } - - #endif // UNITY_EDITOR - ////TODO: Remove IInputStateChangeMonitor from this class when we can break the API void IInputStateChangeMonitor.NotifyControlStateChanged(InputControl control, double time, InputEventPtr eventPtr, long monitorIndex) { From 11c9cf036629d7454aa5b75c3e31c2cc21273d5f Mon Sep 17 00:00:00 2001 From: leonardo Date: Sat, 10 May 2025 01:40:14 +0200 Subject: [PATCH 3/6] Moved a lot of editor code into its own assembly. --- .../InputSystem/AssemblyInfo.cs | 1 + .../Editor/Actions/AxisCompositeEditor.cs | 4 +- .../Interactions/HoldInteractionEditor.cs | 10 +- .../Interactions/MultiTapInteractionEditor.cs | 12 +- .../Interactions/PressInteractionEditor.cs | 8 +- .../Interactions/SlowTapInteractionEditor.cs | 9 +- .../Interactions/TapInteractionEditor.cs | 11 +- .../Editor/Actions/Vector2CompositeEditor.cs | 5 +- .../Editor/Actions/Vector3CompositeEditor.cs | 5 +- .../Processors/AxisDeadzoneProcessorEditor.cs | 9 +- .../StickDeadzoneProcessorEditor.cs | 11 +- .../Editor/EditorInitialization.cs | 49 ++++++++ .../Editor/EditorInitialization.cs.meta | 2 + .../EnhancedTouch/TouchSimulationEditor.cs | 16 +-- .../Editor/Plugins/HID/HIDSupportEditor.cs | 21 ++++ .../Plugins/HID/HIDSupportEditor.cs.meta | 2 + .../Plugins/InputSettingsiOSProvider.cs | 1 + .../Editor/Plugins/OnScreenControlEditor.cs | 13 +++ .../Plugins/OnScreenControlEditor.cs.meta | 2 + .../PlayerInput/PlayerInputManagerEditor.cs | 3 + .../Editor/Plugins/PlayerInputEditor.cs | 3 + .../Editor/Settings/InputSettingsProvider.cs | 1 + .../Editor/UnityEditor.InputSystem.asmdef | 105 +++++++++++++++++- .../InputSystem/InputAnalytics.cs | 11 +- .../InputSystem/InputManager.cs | 14 ++- .../InputSystem/InputSystem.cs | 49 +++++--- .../InputSystem/InputSystemObject.cs | 2 + .../InputSystem/Plugins/HID/HIDSupport.cs | 22 +--- .../InputForUI/InputActionAssetVerifier.cs | 2 +- .../Plugins/OnScreen/OnScreenControl.cs | 10 -- .../Plugins/PlayerInput/PlayerInput.cs | 3 - .../InputSystem/ShouldBeEditor.meta | 8 ++ .../InputSystem/ShouldBeEditor/Analytics.meta | 8 ++ .../Analytics/InputExitPlayModeAnalytic.cs | 2 +- .../InputExitPlayModeAnalytic.cs.meta | 0 .../InputSystem/ShouldBeEditor/Settings.meta | 8 ++ .../Settings/InputEditorUserSettings.cs | 2 + .../Settings/InputEditorUserSettings.cs.meta | 0 38 files changed, 353 insertions(+), 91 deletions(-) create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/EditorInitialization.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/EditorInitialization.cs.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/HID/HIDSupportEditor.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/HID/HIDSupportEditor.cs.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreenControlEditor.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreenControlEditor.cs.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Analytics.meta rename Packages/com.unity.inputsystem/InputSystem/{Editor => ShouldBeEditor}/Analytics/InputExitPlayModeAnalytic.cs (99%) rename Packages/com.unity.inputsystem/InputSystem/{Editor => ShouldBeEditor}/Analytics/InputExitPlayModeAnalytic.cs.meta (100%) create mode 100644 Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Settings.meta rename Packages/com.unity.inputsystem/InputSystem/{Editor => ShouldBeEditor}/Settings/InputEditorUserSettings.cs (99%) rename Packages/com.unity.inputsystem/InputSystem/{Editor => ShouldBeEditor}/Settings/InputEditorUserSettings.cs.meta (100%) diff --git a/Packages/com.unity.inputsystem/InputSystem/AssemblyInfo.cs b/Packages/com.unity.inputsystem/InputSystem/AssemblyInfo.cs index 2afe18fc61..97da42ac58 100644 --- a/Packages/com.unity.inputsystem/InputSystem/AssemblyInfo.cs +++ b/Packages/com.unity.inputsystem/InputSystem/AssemblyInfo.cs @@ -8,6 +8,7 @@ [assembly: InternalsVisibleTo("Unity.InputSystem.Tests")] [assembly: InternalsVisibleTo("Unity.InputSystem.IntegrationTests")] [assembly: InternalsVisibleTo("Unity.InputSystem.ForUI")] // To avoid minor bump +[assembly: InternalsVisibleTo("UnityEditor.InputSystem")] namespace UnityEngine.InputSystem { diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/AxisCompositeEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/AxisCompositeEditor.cs index 33c427f238..75c3a2edc6 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/AxisCompositeEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/AxisCompositeEditor.cs @@ -1,8 +1,10 @@ #if UNITY_EDITOR using System; using UnityEditor; +using UnityEngine; using UnityEngine.InputSystem.Editor; using UnityEngine.UIElements; +using UnityEngine.InputSystem.Composites; #endif namespace UnityEditor.InputSystem.Composites { @@ -17,7 +19,7 @@ internal class AxisCompositeEditor : InputParameterEditor public override void OnGUI() { #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; + if (!UnityEngine.InputSystem.InputSystem.settings.useIMGUIEditorForAssets) return; #endif target.whichSideWins = (AxisComposite.WhichSideWins)EditorGUILayout.EnumPopup(m_WhichAxisWinsLabel, target.whichSideWins); } diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/HoldInteractionEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/HoldInteractionEditor.cs index 286f543215..7a417fee62 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/HoldInteractionEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/HoldInteractionEditor.cs @@ -1,11 +1,15 @@ #if UNITY_EDITOR +using System; +using UnityEngine.InputSystem; using UnityEngine.InputSystem.Editor; using UnityEngine.UIElements; +using UnityEngine.InputSystem.Interactions; +using UnityEngine.InputSystem.Controls; #endif namespace UnityEditor.InputSystem.Interactions { - #if UNITY_EDITOR +#if UNITY_EDITOR /// /// UI that is displayed when editing in the editor. /// @@ -20,13 +24,13 @@ protected override void OnEnable() m_DurationSetting.Initialize("Hold Time", "Time (in seconds) that a control has to be held in order for it to register as a hold.", "Default Hold Time", - () => target.duration, x => target.duration = x, () => InputSystem.settings.defaultHoldTime); + () => target.duration, x => target.duration = x, () => UnityEngine.InputSystem.InputSystem.settings.defaultHoldTime); } public override void OnGUI() { #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; + if (!UnityEngine.InputSystem.InputSystem.settings.useIMGUIEditorForAssets) return; #endif m_PressPointSetting.OnGUI(); m_DurationSetting.OnGUI(); diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/MultiTapInteractionEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/MultiTapInteractionEditor.cs index bd480bafd5..daed4821c6 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/MultiTapInteractionEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/MultiTapInteractionEditor.cs @@ -1,8 +1,12 @@ #if UNITY_EDITOR +using System; using UnityEditor; +using UnityEngine; +using UnityEngine.InputSystem; using UnityEngine.InputSystem.Editor; using UnityEngine.UIElements; using UnityEditor.UIElements; +using UnityEngine.InputSystem.Interactions; #endif namespace UnityEditor.InputSystem.Interactions { @@ -19,23 +23,23 @@ protected override void OnEnable() "Time (in seconds) within with a control has to be released again for it to register as a tap. If the control is held " + "for longer than this time, the tap is canceled.", "Default Tap Time", - () => target.tapTime, x => target.tapTime = x, () => InputSystem.settings.defaultTapTime); + () => target.tapTime, x => target.tapTime = x, () => UnityEngine.InputSystem.InputSystem.settings.defaultTapTime); m_TapDelaySetting.Initialize("Max Tap Spacing", "The maximum delay (in seconds) allowed between each tap. If this time is exceeded, the multi-tap is canceled.", "Default Tap Spacing", - () => target.tapDelay, x => target.tapDelay = x, () => InputSystem.settings.multiTapDelayTime); + () => target.tapDelay, x => target.tapDelay = x, () => UnityEngine.InputSystem.InputSystem.settings.multiTapDelayTime); m_PressPointSetting.Initialize("Press Point", "The amount of actuation a control requires before being considered pressed. If not set, default to " + "'Default Button Press Point' in the global input settings.", "Default Button Press Point", () => target.pressPoint, v => target.pressPoint = v, - () => InputSystem.settings.defaultButtonPressPoint); + () => UnityEngine.InputSystem.InputSystem.settings.defaultButtonPressPoint); } public override void OnGUI() { #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; + if (!UnityEngine.InputSystem.InputSystem.settings.useIMGUIEditorForAssets) return; #endif target.tapCount = EditorGUILayout.IntField(m_TapCountLabel, target.tapCount); m_TapDelaySetting.OnGUI(); diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/PressInteractionEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/PressInteractionEditor.cs index 9cb81215c2..57f69223bf 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/PressInteractionEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/PressInteractionEditor.cs @@ -1,8 +1,12 @@ #if UNITY_EDITOR +using System; using UnityEditor; +using UnityEngine; +using UnityEngine.InputSystem; using UnityEngine.InputSystem.Editor; using UnityEngine.UIElements; using UnityEditor.UIElements; +using UnityEngine.InputSystem.Interactions; #endif namespace UnityEditor.InputSystem.Interactions { @@ -21,13 +25,13 @@ protected override void OnEnable() + "'Default Button Press Point' in the global input settings.", "Default Button Press Point", () => target.pressPoint, v => target.pressPoint = v, - () => InputSystem.settings.defaultButtonPressPoint); + () => UnityEngine.InputSystem.InputSystem.settings.defaultButtonPressPoint); } public override void OnGUI() { #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; + if (!UnityEngine.InputSystem.InputSystem.settings.useIMGUIEditorForAssets) return; #endif EditorGUILayout.HelpBox(s_HelpBoxText); target.behavior = (PressBehavior)EditorGUILayout.EnumPopup(s_PressBehaviorLabel, target.behavior); diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/SlowTapInteractionEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/SlowTapInteractionEditor.cs index 6ab05f9290..473dfc3bfc 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/SlowTapInteractionEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/SlowTapInteractionEditor.cs @@ -1,6 +1,9 @@ #if UNITY_EDITOR +using System; +using UnityEngine.InputSystem; using UnityEngine.InputSystem.Editor; using UnityEngine.UIElements; +using UnityEngine.InputSystem.Interactions; #endif namespace UnityEditor.InputSystem.Interactions { @@ -13,19 +16,19 @@ protected override void OnEnable() "Minimum time (in seconds) that a control has to be held for it to register as a slow tap. If the control is released " + "before this time, the slow tap is canceled.", "Default Slow Tap Time", - () => target.duration, x => target.duration = x, () => InputSystem.settings.defaultSlowTapTime); + () => target.duration, x => target.duration = x, () => UnityEngine.InputSystem.InputSystem.settings.defaultSlowTapTime); m_PressPointSetting.Initialize("Press Point", "The amount of actuation a control requires before being considered pressed. If not set, default to " + "'Default Button Press Point' in the global input settings.", "Default Button Press Point", () => target.pressPoint, v => target.pressPoint = v, - () => InputSystem.settings.defaultButtonPressPoint); + () => UnityEngine.InputSystem.InputSystem.settings.defaultButtonPressPoint); } public override void OnGUI() { #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; + if (!UnityEngine.InputSystem.InputSystem.settings.useIMGUIEditorForAssets) return; #endif m_DurationSetting.OnGUI(); m_PressPointSetting.OnGUI(); diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/TapInteractionEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/TapInteractionEditor.cs index 3f07fa9c7d..cf8ab4b39a 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/TapInteractionEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Interactions/TapInteractionEditor.cs @@ -1,6 +1,9 @@ #if UNITY_EDITOR +using System; +using UnityEngine.InputSystem; using UnityEngine.InputSystem.Editor; using UnityEngine.UIElements; +using UnityEngine.InputSystem.Interactions; #endif namespace UnityEditor.InputSystem.Interactions { @@ -12,20 +15,20 @@ protected override void OnEnable() m_DurationSetting.Initialize("Max Tap Duration", "Time (in seconds) within with a control has to be released again for it to register as a tap. If the control is held " + "for longer than this time, the tap is canceled.", - "Default Tap Time", - () => target.duration, x => target.duration = x, () => InputSystem.settings.defaultTapTime); + "Default Tap Time", + () => target.duration, x => target.duration = x, () => UnityEngine.InputSystem.InputSystem.settings.defaultTapTime); m_PressPointSetting.Initialize("Press Point", "The amount of actuation a control requires before being considered pressed. If not set, default to " + "'Default Button Press Point' in the global input settings.", "Default Button Press Point", () => target.pressPoint, v => target.pressPoint = v, - () => InputSystem.settings.defaultButtonPressPoint); + () => UnityEngine.InputSystem.InputSystem.settings.defaultButtonPressPoint); } public override void OnGUI() { #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; + if (!UnityEngine.InputSystem.InputSystem.settings.useIMGUIEditorForAssets) return; #endif m_DurationSetting.OnGUI(); m_PressPointSetting.OnGUI(); diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector2CompositeEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector2CompositeEditor.cs index baad150428..83d529b3ac 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector2CompositeEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector2CompositeEditor.cs @@ -1,7 +1,10 @@ #if UNITY_EDITOR +using System; using UnityEditor; +using UnityEngine; using UnityEngine.InputSystem.Editor; using UnityEngine.UIElements; +using UnityEngine.InputSystem.Composites; #endif namespace UnityEditor.InputSystem.Composites { @@ -16,7 +19,7 @@ internal class Vector2CompositeEditor : InputParameterEditor public override void OnGUI() { #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; + if (!UnityEngine.InputSystem.InputSystem.settings.useIMGUIEditorForAssets) return; #endif target.mode = (Vector2Composite.Mode)EditorGUILayout.EnumPopup(m_ModeLabel, target.mode); } diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector3CompositeEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector3CompositeEditor.cs index c540c98402..ba53d4c9a5 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector3CompositeEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Actions/Vector3CompositeEditor.cs @@ -1,8 +1,11 @@ #if UNITY_EDITOR +using System; using UnityEditor; +using UnityEngine; using UnityEngine.InputSystem.Editor; using UnityEngine.UIElements; +using UnityEngine.InputSystem.Composites; #endif namespace UnityEditor.InputSystem.Composites { @@ -17,7 +20,7 @@ internal class Vector3CompositeEditor : InputParameterEditor public override void OnGUI() { #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; + if (!UnityEngine.InputSystem.InputSystem.settings.useIMGUIEditorForAssets) return; #endif target.mode = (Vector3Composite.Mode)EditorGUILayout.EnumPopup(m_ModeLabel, target.mode); } diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/AxisDeadzoneProcessorEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/AxisDeadzoneProcessorEditor.cs index 3c1f7b5ede..cf98563d74 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/AxisDeadzoneProcessorEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/AxisDeadzoneProcessorEditor.cs @@ -1,7 +1,10 @@ #if UNITY_EDITOR +using System; +using UnityEngine.InputSystem; using UnityEngine.InputSystem.Editor; using UnityEngine.UIElements; +using UnityEngine.InputSystem.Processors; #endif namespace UnityEditor.InputSystem.Processors { @@ -15,18 +18,18 @@ protected override void OnEnable() "Value below which input values will be clamped. After clamping, values will be renormalized to [0..1] between min and max.", "Default Deadzone Min", () => target.min, v => target.min = v, - () => InputSystem.settings.defaultDeadzoneMin); + () => UnityEngine.InputSystem.InputSystem.settings.defaultDeadzoneMin); m_MaxSetting.Initialize("Max", "Value above which input values will be clamped. After clamping, values will be renormalized to [0..1] between min and max.", "Default Deadzone Max", () => target.max, v => target.max = v, - () => InputSystem.settings.defaultDeadzoneMax); + () => UnityEngine.InputSystem.InputSystem.settings.defaultDeadzoneMax); } public override void OnGUI() { #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; + if (!UnityEngine.InputSystem.InputSystem.settings.useIMGUIEditorForAssets) return; #endif m_MinSetting.OnGUI(); m_MaxSetting.OnGUI(); diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/StickDeadzoneProcessorEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/StickDeadzoneProcessorEditor.cs index 227f2cc199..fbc36efe6b 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/StickDeadzoneProcessorEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Controls/Processors/StickDeadzoneProcessorEditor.cs @@ -1,8 +1,9 @@ - - #if UNITY_EDITOR +using System; +using UnityEngine.InputSystem; using UnityEngine.InputSystem.Editor; using UnityEngine.UIElements; +using UnityEngine.InputSystem.Processors; #endif namespace UnityEditor.InputSystem.Processors { @@ -16,18 +17,18 @@ protected override void OnEnable() "Vector length below which input values will be clamped. After clamping, vector lengths will be renormalized to [0..1] between min and max.", "Default Deadzone Min", () => target.min, v => target.min = v, - () => InputSystem.settings.defaultDeadzoneMin); + () => UnityEngine.InputSystem.InputSystem.settings.defaultDeadzoneMin); m_MaxSetting.Initialize("Max", "Vector length above which input values will be clamped. After clamping, vector lengths will be renormalized to [0..1] between min and max.", "Default Deadzone Max", () => target.max, v => target.max = v, - () => InputSystem.settings.defaultDeadzoneMax); + () => UnityEngine.InputSystem.InputSystem.settings.defaultDeadzoneMax); } public override void OnGUI() { #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS - if (!InputSystem.settings.useIMGUIEditorForAssets) return; + if (!UnityEngine.InputSystem.InputSystem.settings.useIMGUIEditorForAssets) return; #endif m_MinSetting.OnGUI(); m_MaxSetting.OnGUI(); diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/EditorInitialization.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/EditorInitialization.cs new file mode 100644 index 0000000000..857cf96af0 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/EditorInitialization.cs @@ -0,0 +1,49 @@ +using UnityEditor; +using UnityEngine; +using UnityEngine.InputSystem; +using UnityEngine.InputSystem.Editor; +using UnityEngine.InputSystem.HID; + + +[InitializeOnLoad] +static class EditorInitialization { + static EditorInitialization() { + + UnityEngine.InputSystem.InputSystem.SetBuildSettingsConfigKey(InputSettingsProvider.kEditorBuildSettingsConfigKey); + +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + UnityEngine.InputSystem.InputSystem.SetActionSetEvent((actionsAsset) => { UnityEngine.InputSystem.Editor.ProjectWideActionsBuildProvider.actionsToIncludeInPlayerBuild = actionsAsset;}); +#endif + + UnityEngine.InputSystem.InputSystem.m_InputDebuggerWindowReviveAfterDomainReload = () => InputDebuggerWindow.ReviveAfterDomainReload(); + +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + UnityEngine.InputSystem.InputSystem.m_ProjectWideActionsBuildProviderActionsToIncludeInPlayerBuild = () => { return UnityEngine.InputSystem.Editor.ProjectWideActionsBuildProvider.actionsToIncludeInPlayerBuild; }; +#endif + UnityEngine.InputSystem.InputSystem.m_EditorPlayerSettingHelpersGetNewSystemBackendsEnabled = () => { return EditorPlayerSettingHelpers.newSystemBackendsEnabled; }; + + UnityEngine.InputSystem.InputSystem.m_EditorPlayerSettingHelpersSetNewSystemBackendsEnabled = (val) => { EditorPlayerSettingHelpers.newSystemBackendsEnabled = val; }; + +#if UNITY_2023_2_OR_NEWER + InputAnalytics.StartupEventAnalytic.m_EditorPlayerSettingHelpersGetNewSystemBackendsEnabled = () => { return EditorPlayerSettingHelpers.newSystemBackendsEnabled; }; + InputAnalytics.StartupEventAnalytic.m_EditorPlayerSettingHelpersGetOldSystemBackendsEnabled = () => { return EditorPlayerSettingHelpers.oldSystemBackendsEnabled; }; +#endif + UnityEngine.InputSystem.InputSystem.m_EditorHelpersRestartEditorAndRecompileScripts = () => { EditorHelpers.RestartEditorAndRecompileScripts(); }; + + UnityEngine.InputSystem.InputSystem.m_InputSettingsProviderForceReload = () => { InputSettingsProvider.ForceReload(); }; + + UnityEngine.InputSystem.InputSystem.m_OnDestroyCallback = () => { + EditorInputControlLayoutCache.Clear(); + InputDeviceDebuggerWindow.s_OnToolbarGUIActions.Clear(); + }; + + HIDSupport.m_InitializeInputDeviceDebuggerWindowOnToolbarGUI = () => { InputDeviceDebuggerWindow.onToolbarGUI += HIDSupportEditor.InputDeviceDebuggerWindowToolbarGUI; }; + + InputManager.m_InputEditorUserSettingsAddDevicesNotSupportedByProject = () => { return InputEditorUserSettings.addDevicesNotSupportedByProject; }; +#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS + InputManager.m_ProjectWideActionsBuildProviderActionsToIncludeInPlayerBuild = () => { return UnityEngine.InputSystem.Editor.ProjectWideActionsBuildProvider.actionsToIncludeInPlayerBuild; }; +#endif + + UnityEngine.InputSystem.InputSystem.InitializeInEditor(); + } +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/EditorInitialization.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/EditorInitialization.cs.meta new file mode 100644 index 0000000000..e6572585e0 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/EditorInitialization.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 3a0aaae5cb7b741509e7b6e4087e8880 \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/EnhancedTouch/TouchSimulationEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/EnhancedTouch/TouchSimulationEditor.cs index 25fe546389..1e4b08903f 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/EnhancedTouch/TouchSimulationEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/EnhancedTouch/TouchSimulationEditor.cs @@ -1,14 +1,16 @@ #if UNITY_EDITOR using UnityEditor; using UnityEngine.InputSystem.Editor; +using UnityEngine.InputSystem.EnhancedTouch; +using UnityEngine.InputSystem; #endif -namespace UnityEngine.InputSystem.EnhancedTouch { +namespace UnityEditor.InputSystem.EnhancedTouch { [InitializeOnLoad] - private class TouchSimulationEdtiorInitialization + class TouchSimulationEdtiorInitialization { - static TouchSimulation() + static TouchSimulationEdtiorInitialization() { // We're a MonoBehaviour so our cctor may get called as part of the MonoBehaviour being // created. We don't want to trigger InputSystem initialization from there so delay-execute @@ -16,15 +18,15 @@ static TouchSimulation() EditorApplication.delayCall += () => { - InputSystem.onSettingsChange += OnSettingsChanged; - InputSystem.onBeforeUpdate += ReEnableAfterDomainReload; + UnityEngine.InputSystem.InputSystem.onSettingsChange += OnSettingsChanged; + UnityEngine.InputSystem.InputSystem.onBeforeUpdate += ReEnableAfterDomainReload; }; } private static void ReEnableAfterDomainReload() { OnSettingsChanged(); - InputSystem.onBeforeUpdate -= ReEnableAfterDomainReload; + UnityEngine.InputSystem.InputSystem.onBeforeUpdate -= ReEnableAfterDomainReload; } private static void OnSettingsChanged() @@ -39,7 +41,7 @@ private static void OnSettingsChanged() [CustomEditor(typeof(TouchSimulation))] - private class TouchSimulationEditor : UnityEditor.Editor + class TouchSimulationEditor : UnityEditor.Editor { public void OnDisable() { diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/HID/HIDSupportEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/HID/HIDSupportEditor.cs new file mode 100644 index 0000000000..3c47699a41 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/HID/HIDSupportEditor.cs @@ -0,0 +1,21 @@ +using UnityEditor; +using UnityEngine.InputSystem.HID.Editor; + +namespace UnityEngine.InputSystem.HID { + + internal static class HIDSupportEditor { + private static readonly GUIContent s_HIDDescriptor = new GUIContent("HID Descriptor"); + + internal static void InputDeviceDebuggerWindowToolbarGUI(InputDevice device) { + if (device.description.interfaceName == HID.kHIDInterface) + { + if (GUILayout.Button(s_HIDDescriptor, EditorStyles.toolbarButton)) + { + HIDDescriptorWindow.CreateOrShowExisting(device.deviceId, device.description); + } + } + } + } + + +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/HID/HIDSupportEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/HID/HIDSupportEditor.cs.meta new file mode 100644 index 0000000000..8079d0cf7a --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/HID/HIDSupportEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 76cd46166f0ed481cb5a81428c2efe5f \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/InputSettingsiOSProvider.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/InputSettingsiOSProvider.cs index 159f21efed..cca43b1e25 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/InputSettingsiOSProvider.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/InputSettingsiOSProvider.cs @@ -1,6 +1,7 @@ #if UNITY_EDITOR using System; using UnityEditor; +using UnityEngine; namespace UnityEditor.InputSystem { diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreenControlEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreenControlEditor.cs new file mode 100644 index 0000000000..735e15beae --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreenControlEditor.cs @@ -0,0 +1,13 @@ +using UnityEditor; +using UnityEngine.InputSystem.OnScreen; + +namespace UnityEditor.InputSystem.OnScreen { + internal static class UGUIOnScreenControlEditorUtils + { + public static void ShowWarningIfNotPartOfCanvasHierarchy(OnScreenControl target) + { + if (UGUIOnScreenControlUtils.GetCanvasRectTransform(target.transform) == null) + UnityEditor.EditorGUILayout.HelpBox(target.GetWarningMessage(), UnityEditor.MessageType.Warning); + } + } +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreenControlEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreenControlEditor.cs.meta new file mode 100644 index 0000000000..d9d50d050c --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreenControlEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: e34cba92dc6a9445a946358110d4c11e \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInput/PlayerInputManagerEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInput/PlayerInputManagerEditor.cs index 5555838bc1..2d22427ae0 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInput/PlayerInputManagerEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInput/PlayerInputManagerEditor.cs @@ -2,7 +2,10 @@ using System; using System.Linq; using UnityEditor; +using UnityEngine; +using UnityEngine.InputSystem; using UnityEngine.InputSystem.Users; +using UnityEngine.InputSystem.Editor; namespace UnityEditor.InputSystem.Editor { diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInputEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInputEditor.cs index a8114b1061..5d7a5eb353 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInputEditor.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/PlayerInputEditor.cs @@ -5,8 +5,11 @@ using System.Linq; using System.Text; using UnityEditor; +using UnityEngine; using UnityEngine.InputSystem.Users; using UnityEngine.InputSystem.Utilities; +using UnityEngine.InputSystem; +using UnityEngine.InputSystem.Editor; #if UNITY_INPUT_SYSTEM_ENABLE_UI using UnityEngine.InputSystem.UI; diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputSettingsProvider.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputSettingsProvider.cs index 1b333b0ed4..46e64e4cdf 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputSettingsProvider.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputSettingsProvider.cs @@ -5,6 +5,7 @@ using UnityEditorInternal; using UnityEngine.InputSystem.Utilities; using UnityEngine.UIElements; +using UnityEditor.InputSystem; ////TODO: detect if new input backends are enabled and put UI in here to enable them if needed diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UnityEditor.InputSystem.asmdef b/Packages/com.unity.inputsystem/InputSystem/Editor/UnityEditor.InputSystem.asmdef index efdc92ba6e..b18f261b00 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UnityEditor.InputSystem.asmdef +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UnityEditor.InputSystem.asmdef @@ -8,11 +8,112 @@ "Editor" ], "excludePlatforms": [], - "allowUnsafeCode": false, + "allowUnsafeCode": true, "overrideReferences": false, "precompiledReferences": [], "autoReferenced": true, "defineConstraints": [], - "versionDefines": [], + "versionDefines": [ + { + "name": "com.unity.xr.oculus", + "expression": "1.0.3", + "define": "DISABLE_BUILTIN_INPUT_SYSTEM_OCULUS" + }, + { + "name": "com.unity.xr.googlevr", + "expression": "1.0.0", + "define": "DISABLE_BUILTIN_INPUT_SYSTEM_GOOGLEVR" + }, + { + "name": "com.unity.xr.openvr", + "expression": "1.0.0", + "define": "DISABLE_BUILTIN_INPUT_SYSTEM_OPENVR" + }, + { + "name": "com.unity.xr.windowsmr", + "expression": "2.0.3", + "define": "DISABLE_BUILTIN_INPUT_SYSTEM_WINDOWSMR" + }, + { + "name": "com.unity.modules.vr", + "expression": "1.0.0", + "define": "UNITY_INPUT_SYSTEM_ENABLE_VR" + }, + { + "name": "com.unity.modules.xr", + "expression": "1.0.0", + "define": "UNITY_INPUT_SYSTEM_ENABLE_XR" + }, + { + "name": "com.unity.modules.physics", + "expression": "1.0.0", + "define": "UNITY_INPUT_SYSTEM_ENABLE_PHYSICS" + }, + { + "name": "com.unity.modules.physics2d", + "expression": "1.0.0", + "define": "UNITY_INPUT_SYSTEM_ENABLE_PHYSICS2D" + }, + { + "name": "com.unity.ugui", + "expression": "1.0.0", + "define": "UNITY_INPUT_SYSTEM_ENABLE_UI" + }, + { + "name": "Unity", + "expression": "[2021.3.11,2022.1)", + "define": "HAS_SET_LOCAL_POSITION_AND_ROTATION" + }, + { + "name": "Unity", + "expression": "[2022.1.19,2022.2)", + "define": "HAS_SET_LOCAL_POSITION_AND_ROTATION" + }, + { + "name": "Unity", + "expression": "2022.2", + "define": "HAS_SET_LOCAL_POSITION_AND_ROTATION" + }, + { + "name": "Unity", + "expression": "2022.3", + "define": "UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS" + }, + { + "name": "Unity", + "expression": "1", + "define": "UNITY_INPUT_SYSTEM_INPUT_ACTIONS_EDITOR_AUTO_SAVE_ON_FOCUS_LOST" + }, + { + "name": "Unity", + "expression": "6000.0.9", + "define": "UNITY_INPUT_SYSTEM_PLATFORM_SCROLL_DELTA" + }, + { + "name": "Unity", + "expression": "6000.0.11", + "define": "UNITY_INPUT_SYSTEM_INPUT_MODULE_SCROLL_DELTA" + }, + { + "name": "Unity", + "expression": "6000.1.0b9", + "define": "UNITY_INPUT_SYSTEM_INPUT_MODULE_NAVIGATION_DEVICE_TYPE" + }, + { + "name": "Unity", + "expression": "6000.2.0a4", + "define": "UNITY_INPUT_SYSTEM_INPUT_MODULE_NAVIGATION_DEVICE_TYPE" + }, + { + "name": "Unity", + "expression": "6000.0.15", + "define": "UNITY_INPUT_SYSTEM_SENDPOINTERHOVERTOPARENT" + }, + { + "name": "com.unity.modules.unityanalytics", + "expression": "1", + "define": "UNITY_INPUT_SYSTEM_ENABLE_ANALYTICS" + } + ], "noEngineReferences": false } \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/InputAnalytics.cs b/Packages/com.unity.inputsystem/InputSystem/InputAnalytics.cs index 7593ebacf4..e7dbaf354a 100644 --- a/Packages/com.unity.inputsystem/InputSystem/InputAnalytics.cs +++ b/Packages/com.unity.inputsystem/InputSystem/InputAnalytics.cs @@ -1,9 +1,8 @@ #if UNITY_ANALYTICS || UNITY_EDITOR using System; using UnityEngine.InputSystem.Layouts; -#if UNITY_EDITOR -using UnityEngine.InputSystem.Editor; -#endif // UNITY_EDITOR +using UnityEditor; + ////FIXME: apparently shutdown events are not coming through in the analytics backend @@ -142,6 +141,8 @@ public StartupEventAnalytic(InputManager manager) public InputAnalyticInfo info => new InputAnalyticInfo(kEventName, kMaxEventsPerHour, kMaxNumberOfElements); #if UNITY_EDITOR && UNITY_2023_2_OR_NEWER + internal static Func m_EditorPlayerSettingHelpersGetNewSystemBackendsEnabled; + internal static Func m_EditorPlayerSettingHelpersGetOldSystemBackendsEnabled; public bool TryGatherData(out UnityEngine.Analytics.IAnalytic.IData data, out Exception error) #else public bool TryGatherData(out IInputAnalyticData data, out Exception error) @@ -155,8 +156,8 @@ public bool TryGatherData(out IInputAnalyticData data, out Exception error) devices = CollectRecognizedDevices(m_InputManager), unrecognized_devices = CollectUnrecognizedDevices(m_InputManager), #if UNITY_EDITOR - new_enabled = EditorPlayerSettingHelpers.newSystemBackendsEnabled, - old_enabled = EditorPlayerSettingHelpers.oldSystemBackendsEnabled, + new_enabled = m_EditorPlayerSettingHelpersGetNewSystemBackendsEnabled.Invoke(), + old_enabled = m_EditorPlayerSettingHelpersGetOldSystemBackendsEnabled.Invoke(), #endif // UNITY_EDITOR }; error = null; diff --git a/Packages/com.unity.inputsystem/InputSystem/InputManager.cs b/Packages/com.unity.inputsystem/InputSystem/InputManager.cs index 10e3c17fb8..cb9cfd035e 100644 --- a/Packages/com.unity.inputsystem/InputSystem/InputManager.cs +++ b/Packages/com.unity.inputsystem/InputSystem/InputManager.cs @@ -16,9 +16,6 @@ using UnityEngine.InputSystem.Layouts; using Unity.Profiling; -#if UNITY_EDITOR -using UnityEngine.InputSystem.Editor; -#endif #if UNITY_EDITOR using CustomBindingPathValidator = System.Func; @@ -993,6 +990,10 @@ private InternedString FindOrRegisterDeviceLayoutForType(Type type) return layoutName; } + #if UNITY_EDITOR + internal static Func m_InputEditorUserSettingsAddDevicesNotSupportedByProject; + #endif + /// /// Return true if the given device layout is supported by the game according to . /// @@ -1005,7 +1006,7 @@ private bool IsDeviceLayoutMarkedAsSupportedInSettings(InternedString layoutName // is useful to ensure that things like keyboard, mouse, and pen keep working in the editor // even if not supported as devices in the game. #if UNITY_EDITOR - if (InputEditorUserSettings.addDevicesNotSupportedByProject) + if (m_InputEditorUserSettingsAddDevicesNotSupportedByProject.Invoke()) return true; #endif @@ -1842,6 +1843,9 @@ internal void Destroy() // Project-wide Actions are never temporary so we do not destroy them. } +#if UNITY_EDITOR + internal static Func m_ProjectWideActionsBuildProviderActionsToIncludeInPlayerBuild; +#endif #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS // Initialize project-wide actions: @@ -1850,7 +1854,7 @@ internal void Destroy() private void InitializeActions() { #if UNITY_EDITOR - m_Actions = ProjectWideActionsBuildProvider.actionsToIncludeInPlayerBuild; + m_Actions = m_ProjectWideActionsBuildProviderActionsToIncludeInPlayerBuild.Invoke(); #else m_Actions = null; var candidates = Resources.FindObjectsOfTypeAll(); diff --git a/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs b/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs index eb7a35dcd7..f878d5173c 100644 --- a/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs +++ b/Packages/com.unity.inputsystem/InputSystem/InputSystem.cs @@ -17,8 +17,8 @@ #if UNITY_EDITOR using UnityEditor; -using UnityEngine.InputSystem.Editor; using UnityEditor.Networking.PlayerConnection; +using UnityEngine.InputSystem.Editor; #else using System.Linq; using UnityEngine.Networking.PlayerConnection; @@ -2905,9 +2905,10 @@ public static InputSettings settings // In the editor, we keep track of the settings asset through EditorBuildSettings. #if UNITY_EDITOR + if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(value))) { - EditorBuildSettings.AddConfigObject(InputSettingsProvider.kEditorBuildSettingsConfigKey, + EditorBuildSettings.AddConfigObject(m_EditorBuildSettingsConfigKey, value, true); } #endif @@ -2916,6 +2917,11 @@ public static InputSettings settings } } + static string m_EditorBuildSettingsConfigKey = ""; + public static void SetBuildSettingsConfigKey(string key) { + m_EditorBuildSettingsConfigKey = key; + } + /// /// Event that is triggered if any of the properties in changes or if /// is replaced entirely with a new object. @@ -3114,7 +3120,8 @@ public static InputActionAsset actions // Track reference to enable including it in built Players, note that it will discard any non-persisted // object reference - ProjectWideActionsBuildProvider.actionsToIncludeInPlayerBuild = value; + m_ActionsSetEvent.Invoke(value); + //ProjectWideActionsBuildProvider.actionsToIncludeInPlayerBuild = value; #endif // UNITY_EDITOR // Update underlying value @@ -3124,6 +3131,11 @@ public static InputActionAsset actions } } + internal static Action m_ActionsSetEvent; + internal static void SetActionSetEvent(Action callback){ + m_ActionsSetEvent = callback; + } + /// /// Event that is triggered if the instance assigned to property changes. /// @@ -3502,7 +3514,8 @@ private static bool ShouldEnableRemoting() static InputSystem() { #if UNITY_EDITOR - InitializeInEditor(); + //This will be called by EditorInitialization on the editor assembly + //InitializeInEditor(); #else InitializeInPlayer(); #endif @@ -3535,6 +3548,8 @@ internal static void EnsureInitialized() #if UNITY_EDITOR internal static InputSystemObject s_SystemObject; + internal static Action m_InputDebuggerWindowReviveAfterDomainReload; + internal static Func m_ProjectWideActionsBuildProviderActionsToIncludeInPlayerBuild; internal static void InitializeInEditor(IInputRuntime runtime = null) { @@ -3553,7 +3568,7 @@ internal static void InitializeInEditor(IInputRuntime runtime = null) s_SystemObject = existingSystemObjects[0]; s_Manager.RestoreStateWithoutDevices(s_SystemObject.systemState.managerState); - InputDebuggerWindow.ReviveAfterDomainReload(); + m_InputDebuggerWindowReviveAfterDomainReload.Invoke(); // Restore remoting state. s_RemoteConnection = s_SystemObject.systemState.remoteConnection; @@ -3577,7 +3592,7 @@ internal static void InitializeInEditor(IInputRuntime runtime = null) s_SystemObject.hideFlags = HideFlags.HideAndDontSave; // See if we have a remembered settings object. - if (EditorBuildSettings.TryGetConfigObject(InputSettingsProvider.kEditorBuildSettingsConfigKey, + if (EditorBuildSettings.TryGetConfigObject(m_EditorBuildSettingsConfigKey, out InputSettings settingsAsset)) { if (s_Manager.m_Settings.hideFlags == HideFlags.HideAndDontSave) @@ -3588,7 +3603,8 @@ internal static void InitializeInEditor(IInputRuntime runtime = null) #if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS // See if we have a saved actions object - var savedActions = ProjectWideActionsBuildProvider.actionsToIncludeInPlayerBuild; + var savedActions = m_ProjectWideActionsBuildProviderActionsToIncludeInPlayerBuild.Invoke(); + //var savedActions = ProjectWideActionsBuildProvider.actionsToIncludeInPlayerBuild; if (savedActions != null) s_Manager.actions = savedActions; #endif // UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS @@ -3614,10 +3630,14 @@ internal static void InitializeInEditor(IInputRuntime runtime = null) k_InputInitializeInEditorMarker.End(); } + internal static Func m_EditorPlayerSettingHelpersGetNewSystemBackendsEnabled; //What should the default be? + internal static Action m_EditorPlayerSettingHelpersSetNewSystemBackendsEnabled; + internal static Action m_EditorHelpersRestartEditorAndRecompileScripts; + private static void ShowRestartWarning() { if (!s_SystemObject.newInputBackendsCheckedAsEnabled && - !EditorPlayerSettingHelpers.newSystemBackendsEnabled && + !m_EditorPlayerSettingHelpersGetNewSystemBackendsEnabled.Invoke() && !s_Manager.m_Runtime.isInBatchMode) { const string dialogText = "This project is using the new input system package but the native platform backends for the new input system are not enabled in the player settings. " + @@ -3626,8 +3646,9 @@ private static void ShowRestartWarning() if (EditorUtility.DisplayDialog("Warning", dialogText, "Yes", "No")) { - EditorPlayerSettingHelpers.newSystemBackendsEnabled = true; - EditorHelpers.RestartEditorAndRecompileScripts(); + + m_EditorPlayerSettingHelpersSetNewSystemBackendsEnabled.Invoke(true); + m_EditorHelpersRestartEditorAndRecompileScripts.Invoke(); } } s_SystemObject.newInputBackendsCheckedAsEnabled = true; @@ -3705,12 +3726,13 @@ internal static void OnPlayModeChange(PlayModeStateChange change) } } + internal static Action m_InputSettingsProviderForceReload; private static void OnProjectChange() { ////TODO: use dirty count to find whether settings have actually changed // May have added, removed, moved, or renamed settings asset. Force a refresh // of the UI. - InputSettingsProvider.ForceReload(); + m_InputSettingsProviderForceReload.Invoke(); // Also, if the asset holding our current settings got deleted, switch back to a // temporary settings object. @@ -3920,6 +3942,8 @@ private static void Reset(bool enableRemoting = false, IInputRuntime runtime = n k_InputResetMarker.End(); } + internal static Action m_OnDestroyCallback; + /// /// Destroy the current setup of the input system. /// @@ -3935,8 +3959,7 @@ private static void Destroy() if (s_RemoteConnection != null) Object.DestroyImmediate(s_RemoteConnection); #if UNITY_EDITOR - EditorInputControlLayoutCache.Clear(); - InputDeviceDebuggerWindow.s_OnToolbarGUIActions.Clear(); + m_OnDestroyCallback.Invoke(); InputEditorUserSettings.s_Settings = new InputEditorUserSettings.SerializedState(); #endif diff --git a/Packages/com.unity.inputsystem/InputSystem/InputSystemObject.cs b/Packages/com.unity.inputsystem/InputSystem/InputSystemObject.cs index 4bb0ddc027..0b9b2fc154 100644 --- a/Packages/com.unity.inputsystem/InputSystem/InputSystemObject.cs +++ b/Packages/com.unity.inputsystem/InputSystem/InputSystemObject.cs @@ -18,6 +18,8 @@ internal class InputSystemObject : ScriptableObject, ISerializationCallbackRecei [SerializeField] public double exitEditModeTime; [SerializeField] public double enterPlayModeTime; + static InputEditorUserSettings.SerializedState m_InputEditorUserSettingsS_Settings; + public void OnBeforeSerialize() { // Save current system state. diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/HID/HIDSupport.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/HID/HIDSupport.cs index 29341e26d8..4b9d5351ed 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/HID/HIDSupport.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/HID/HIDSupport.cs @@ -1,9 +1,8 @@ +using System; using System.Linq; using UnityEngine.InputSystem.Utilities; #if UNITY_EDITOR using UnityEditor; -using UnityEngine.InputSystem.Editor; -using UnityEngine.InputSystem.HID.Editor; #endif namespace UnityEngine.InputSystem.HID @@ -109,6 +108,9 @@ public static ReadOnlyArray supportedHIDUsages } } } + #if UNITY_EDITOR + internal static Action m_InitializeInputDeviceDebuggerWindowOnToolbarGUI; + #endif /// /// Add support for generic HIDs to InputSystem. @@ -133,22 +135,8 @@ static void Initialize() // Add toolbar button to any devices using the "HID" interface. Opens // a windows to browse the HID descriptor of the device. #if UNITY_EDITOR - InputDeviceDebuggerWindow.onToolbarGUI += - device => - { - if (device.description.interfaceName == HID.kHIDInterface) - { - if (GUILayout.Button(s_HIDDescriptor, EditorStyles.toolbarButton)) - { - HIDDescriptorWindow.CreateOrShowExisting(device.deviceId, device.description); - } - } - }; + m_InitializeInputDeviceDebuggerWindowOnToolbarGUI.Invoke(); #endif } - - #if UNITY_EDITOR - private static readonly GUIContent s_HIDDescriptor = new GUIContent("HID Descriptor"); - #endif } } diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputActionAssetVerifier.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputActionAssetVerifier.cs index f42433be8b..ae9ff3bbb6 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputActionAssetVerifier.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/InputForUI/InputActionAssetVerifier.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && ENABLE_INPUT_SYSTEM && UNITY_2023_2_OR_NEWER +#if UNITY_EDITOR && ENABLE_INPUT_SYSTEM && UNITY_2023_2_OR_NEWER && UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS using System.Collections.Generic; using UnityEditor; using UnityEngine.InputSystem.Editor; diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenControl.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenControl.cs index 06b464802f..1f824baff9 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenControl.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenControl.cs @@ -356,14 +356,4 @@ public static RectTransform GetCanvasRectTransform(Transform transform) } } -#if UNITY_EDITOR - internal static class UGUIOnScreenControlEditorUtils - { - public static void ShowWarningIfNotPartOfCanvasHierarchy(OnScreenControl target) - { - if (UGUIOnScreenControlUtils.GetCanvasRectTransform(target.transform) == null) - UnityEditor.EditorGUILayout.HelpBox(target.GetWarningMessage(), UnityEditor.MessageType.Warning); - } - } -#endif } diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInput.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInput.cs index 00c09d7bed..5611c734c9 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInput.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInput.cs @@ -6,9 +6,6 @@ using UnityEngine.InputSystem.Utilities; using UnityEngine.InputSystem.OnScreen; -#if UNITY_EDITOR -using UnityEngine.InputSystem.Editor; -#endif #if PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI using UnityEngine.InputSystem.UI; diff --git a/Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor.meta b/Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor.meta new file mode 100644 index 0000000000..27bb55c817 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4b7277f5c8761471da1af5fd64598376 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Analytics.meta b/Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Analytics.meta new file mode 100644 index 0000000000..0f0ed59dfb --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Analytics.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 63b6a9813bf5740c5b8c2cd9c1b8518d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputExitPlayModeAnalytic.cs b/Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Analytics/InputExitPlayModeAnalytic.cs similarity index 99% rename from Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputExitPlayModeAnalytic.cs rename to Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Analytics/InputExitPlayModeAnalytic.cs index a978775bca..fbadbec0ca 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputExitPlayModeAnalytic.cs +++ b/Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Analytics/InputExitPlayModeAnalytic.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; using UnityEditor; diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputExitPlayModeAnalytic.cs.meta b/Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Analytics/InputExitPlayModeAnalytic.cs.meta similarity index 100% rename from Packages/com.unity.inputsystem/InputSystem/Editor/Analytics/InputExitPlayModeAnalytic.cs.meta rename to Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Analytics/InputExitPlayModeAnalytic.cs.meta diff --git a/Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Settings.meta b/Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Settings.meta new file mode 100644 index 0000000000..3bb337ad3e --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Settings.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8d7cfd10d175c40a5a2c956a9f4ef4f9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputEditorUserSettings.cs b/Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Settings/InputEditorUserSettings.cs similarity index 99% rename from Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputEditorUserSettings.cs rename to Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Settings/InputEditorUserSettings.cs index d2d3527cdb..ea9a36a7f0 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputEditorUserSettings.cs +++ b/Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Settings/InputEditorUserSettings.cs @@ -1,3 +1,5 @@ +using UnityEngine; + #if UNITY_EDITOR using System; using System.IO; diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputEditorUserSettings.cs.meta b/Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Settings/InputEditorUserSettings.cs.meta similarity index 100% rename from Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputEditorUserSettings.cs.meta rename to Packages/com.unity.inputsystem/InputSystem/ShouldBeEditor/Settings/InputEditorUserSettings.cs.meta From 28ef88309c3b822f0c655e573bbe54d6c6752cf0 Mon Sep 17 00:00:00 2001 From: leonardo Date: Sat, 10 May 2025 01:56:08 +0200 Subject: [PATCH 4/6] declare dependency --- Packages/com.unity.inputsystem/package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Packages/com.unity.inputsystem/package.json b/Packages/com.unity.inputsystem/package.json index d8bdccc6ab..14f260b87a 100755 --- a/Packages/com.unity.inputsystem/package.json +++ b/Packages/com.unity.inputsystem/package.json @@ -13,5 +13,8 @@ "touch", "vr", "xr" - ] + ], + "dependencies": { + "com.unity.modules.jsonserialize": "1.0.0" + } } From 63b440db22283ddcee6abbe4cee50a5f0abe960c Mon Sep 17 00:00:00 2001 From: leonardo Date: Sat, 10 May 2025 02:44:04 +0200 Subject: [PATCH 5/6] Fix compilation for when uielements is part of the project --- .../Editor/EditorInitialization.cs | 12 +++ .../InputSystem/Editor/Plugins/OnScreen.meta | 8 ++ .../Plugins/OnScreen/OnScreenButtonEditor.cs | 36 +++++++ .../OnScreen/OnScreenButtonEditor.cs.meta | 2 + .../Plugins/OnScreen/OnScreenStickEditor.cs | 95 +++++++++++++++++++ .../OnScreen/OnScreenStickEditor.cs.meta | 2 + .../InputSystem/Editor/Plugins/UI.meta | 8 ++ .../UI/InputSystemUIInputModuleEditor.cs | 0 .../UI/InputSystemUIInputModuleEditor.cs.meta | 0 .../Plugins/UI/StandaloneInputModuleEditor.cs | 0 .../UI/StandaloneInputModuleEditor.cs.meta | 0 .../Plugins/UI/VirtualMouseInputEditor.cs | 21 ++++ .../UI/VirtualMouseInputEditor.cs.meta | 2 + .../Plugins/OnScreen/OnScreenButton.cs | 31 +----- .../Plugins/OnScreen/OnScreenStick.cs | 89 +++-------------- .../Plugins/UI/InputSystemUIInputModule.cs | 12 +-- .../Plugins/UI/VirtualMouseInput.cs | 13 +-- 17 files changed, 208 insertions(+), 123 deletions(-) create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen/OnScreenButtonEditor.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen/OnScreenButtonEditor.cs.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen/OnScreenStickEditor.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen/OnScreenStickEditor.cs.meta create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI.meta rename Packages/com.unity.inputsystem/InputSystem/{ => Editor}/Plugins/UI/InputSystemUIInputModuleEditor.cs (100%) rename Packages/com.unity.inputsystem/InputSystem/{ => Editor}/Plugins/UI/InputSystemUIInputModuleEditor.cs.meta (100%) rename Packages/com.unity.inputsystem/InputSystem/{ => Editor}/Plugins/UI/StandaloneInputModuleEditor.cs (100%) rename Packages/com.unity.inputsystem/InputSystem/{ => Editor}/Plugins/UI/StandaloneInputModuleEditor.cs.meta (100%) create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI/VirtualMouseInputEditor.cs create mode 100644 Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI/VirtualMouseInputEditor.cs.meta diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/EditorInitialization.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/EditorInitialization.cs index 857cf96af0..1431bdaf15 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/EditorInitialization.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/EditorInitialization.cs @@ -45,5 +45,17 @@ static EditorInitialization() { #endif UnityEngine.InputSystem.InputSystem.InitializeInEditor(); + +#if UNITY_INPUT_SYSTEM_ENABLE_UI + + UnityEngine.InputSystem.UI.InputSystemUIInputModule.m_Reset = (inputModule) => { + var asset = (InputActionAsset)AssetDatabase.LoadAssetAtPath( + UnityEditor.InputSystem.Editor.PlayerInputEditor.kDefaultInputActionsAssetPath, + typeof(InputActionAsset)); + // Setting default asset and actions when creating via inspector + UnityEngine.InputSystem.UI.Editor.InputSystemUIInputModuleEditor.ReassignActions(inputModule, asset); + }; } +#endif + } \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen.meta new file mode 100644 index 0000000000..1fb51b4159 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: deaa7160c96d24ceabbdb2985165be8c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen/OnScreenButtonEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen/OnScreenButtonEditor.cs new file mode 100644 index 0000000000..14f5d51b5b --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen/OnScreenButtonEditor.cs @@ -0,0 +1,36 @@ +#if PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI +using UnityEngine.EventSystems; +using UnityEngine.InputSystem.Layouts; +using UnityEngine.InputSystem.OnScreen; + +using UnityEngine.InputSystem.Editor; +using UnityEngine.InputSystem; + +namespace UnityEditor.InputSystem.OnScreen { + [UnityEditor.CustomEditor(typeof(OnScreenButton))] + internal class OnScreenButtonEditor : UnityEditor.Editor + { + private UnityEditor.SerializedProperty m_ControlPathInternal; + + public void OnEnable() + { + m_ControlPathInternal = serializedObject.FindProperty(OnScreenButton.OnScreenButtonEditorHelper.m_ControlPath); + } + + public void OnDisable() + { + new InputComponentEditorAnalytic(InputSystemComponent.OnScreenButton).Send(); + } + + public override void OnInspectorGUI() + { + // Current implementation has UGUI dependencies (ISXB-915, ISXB-916) + UGUIOnScreenControlEditorUtils.ShowWarningIfNotPartOfCanvasHierarchy((OnScreenButton)target); + + UnityEditor.EditorGUILayout.PropertyField(m_ControlPathInternal); + + serializedObject.ApplyModifiedProperties(); + } + } +} +#endif diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen/OnScreenButtonEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen/OnScreenButtonEditor.cs.meta new file mode 100644 index 0000000000..c58c2c5452 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen/OnScreenButtonEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ec10af04a3b1d402f9693292ed3c663f \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen/OnScreenStickEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen/OnScreenStickEditor.cs new file mode 100644 index 0000000000..67d7bea1b2 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen/OnScreenStickEditor.cs @@ -0,0 +1,95 @@ +#if PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI +using System; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.InputSystem; +using UnityEngine.EventSystems; +using UnityEngine.Serialization; +using UnityEngine.InputSystem.Layouts; +using UnityEngine.InputSystem.Utilities; +using UnityEngine.UI; +using UnityEngine.InputSystem.Controls; +using UnityEngine.InputSystem.OnScreen; + +using UnityEditor; +using UnityEditor.AnimatedValues; +using UnityEngine.InputSystem.Editor; +////TODO: custom icon for OnScreenStick component + +namespace UnityEditor.InputSystem.OnScreen +{ + [CustomEditor(typeof(OnScreenStick))] + internal class OnScreenStickEditor : UnityEditor.Editor + { + private AnimBool m_ShowDynamicOriginOptions; + private AnimBool m_ShowIsolatedInputActions; + + private SerializedProperty m_UseIsolatedInputActions; + private SerializedProperty m_Behaviour; + private SerializedProperty m_ControlPathInternal; + private SerializedProperty m_MovementRange; + private SerializedProperty m_DynamicOriginRange; + private SerializedProperty m_PointerDownAction; + private SerializedProperty m_PointerMoveAction; + + public void OnEnable() + { + m_ShowDynamicOriginOptions = new AnimBool(false); + m_ShowIsolatedInputActions = new AnimBool(false); + + m_UseIsolatedInputActions = serializedObject.FindProperty(OnScreenStick.OnScreenStickEditorHelper.m_UseIsolatedInputActions); + m_Behaviour = serializedObject.FindProperty(OnScreenStick.OnScreenStickEditorHelper.m_Behaviour); + m_ControlPathInternal = serializedObject.FindProperty(OnScreenStick.OnScreenStickEditorHelper.m_ControlPath); + m_MovementRange = serializedObject.FindProperty(OnScreenStick.OnScreenStickEditorHelper.m_MovementRange); + m_DynamicOriginRange = serializedObject.FindProperty(OnScreenStick.OnScreenStickEditorHelper.m_DynamicOriginRange); + m_PointerDownAction = serializedObject.FindProperty(OnScreenStick.OnScreenStickEditorHelper.m_PointerDownAction); + m_PointerMoveAction = serializedObject.FindProperty(OnScreenStick.OnScreenStickEditorHelper.m_PointerMoveAction); + } + + public void OnDisable() + { + // Report analytics + new InputComponentEditorAnalytic(InputSystemComponent.OnScreenStick).Send(); + new OnScreenStickEditorAnalytic(this).Send(); + } + + public override void OnInspectorGUI() + { + // Current implementation has UGUI dependencies (ISXB-915, ISXB-916) + UGUIOnScreenControlEditorUtils.ShowWarningIfNotPartOfCanvasHierarchy((OnScreenStick)target); + + EditorGUILayout.PropertyField(m_MovementRange); + EditorGUILayout.PropertyField(m_ControlPathInternal); + EditorGUILayout.PropertyField(m_Behaviour); + + m_ShowDynamicOriginOptions.target = ((OnScreenStick)target).behaviour == + OnScreenStick.Behaviour.ExactPositionWithDynamicOrigin; + if (EditorGUILayout.BeginFadeGroup(m_ShowDynamicOriginOptions.faded)) + { + EditorGUI.indentLevel++; + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(m_DynamicOriginRange); + if (EditorGUI.EndChangeCheck()) + { + ((OnScreenStick)target).UpdateDynamicOriginClickableArea(); + } + EditorGUI.indentLevel--; + } + EditorGUILayout.EndFadeGroup(); + + EditorGUILayout.PropertyField(m_UseIsolatedInputActions); + m_ShowIsolatedInputActions.target = m_UseIsolatedInputActions.boolValue; + if (EditorGUILayout.BeginFadeGroup(m_ShowIsolatedInputActions.faded)) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(m_PointerDownAction); + EditorGUILayout.PropertyField(m_PointerMoveAction); + EditorGUI.indentLevel--; + } + EditorGUILayout.EndFadeGroup(); + + serializedObject.ApplyModifiedProperties(); + } + } +} +#endif diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen/OnScreenStickEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen/OnScreenStickEditor.cs.meta new file mode 100644 index 0000000000..39b1ccb5a3 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/OnScreen/OnScreenStickEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: b4fc1685f5c944313bcc95eb2a94bbdc \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI.meta new file mode 100644 index 0000000000..7af0385f02 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c6210498d865a43b1b8e0a377f17ccee +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModuleEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI/InputSystemUIInputModuleEditor.cs similarity index 100% rename from Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModuleEditor.cs rename to Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI/InputSystemUIInputModuleEditor.cs diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModuleEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI/InputSystemUIInputModuleEditor.cs.meta similarity index 100% rename from Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModuleEditor.cs.meta rename to Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI/InputSystemUIInputModuleEditor.cs.meta diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/StandaloneInputModuleEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI/StandaloneInputModuleEditor.cs similarity index 100% rename from Packages/com.unity.inputsystem/InputSystem/Plugins/UI/StandaloneInputModuleEditor.cs rename to Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI/StandaloneInputModuleEditor.cs diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/StandaloneInputModuleEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI/StandaloneInputModuleEditor.cs.meta similarity index 100% rename from Packages/com.unity.inputsystem/InputSystem/Plugins/UI/StandaloneInputModuleEditor.cs.meta rename to Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI/StandaloneInputModuleEditor.cs.meta diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI/VirtualMouseInputEditor.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI/VirtualMouseInputEditor.cs new file mode 100644 index 0000000000..dda32ae2c9 --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI/VirtualMouseInputEditor.cs @@ -0,0 +1,21 @@ +#if PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI +using System; +using UnityEngine.InputSystem; +using UnityEngine.InputSystem.LowLevel; +using UnityEngine.UI; +using UnityEngine.InputSystem.UI; + +using UnityEngine.InputSystem.Editor; + +namespace UnityEditor.InputSystem.UI { + [UnityEditor.CustomEditor(typeof(VirtualMouseInput))] + class VirtualMouseInputEditor : UnityEditor.Editor + { + public void OnDisable() + { + new InputComponentEditorAnalytic(InputSystemComponent.VirtualMouseInput).Send(); + new VirtualMouseInputEditorAnalytic(this).Send(); + } + } +} +#endif // PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI/VirtualMouseInputEditor.cs.meta b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI/VirtualMouseInputEditor.cs.meta new file mode 100644 index 0000000000..946f7c2f1e --- /dev/null +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Plugins/UI/VirtualMouseInputEditor.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 0537f205392654ccbaca8b1f35970e2b \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs index 74308b3a2f..908455aec8 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs @@ -49,33 +49,12 @@ protected override string controlPathInternal set => m_ControlPath = value; } -#if UNITY_EDITOR - [UnityEditor.CustomEditor(typeof(OnScreenButton))] - internal class OnScreenButtonEditor : UnityEditor.Editor - { - private UnityEditor.SerializedProperty m_ControlPathInternal; - - public void OnEnable() - { - m_ControlPathInternal = serializedObject.FindProperty(nameof(OnScreenButton.m_ControlPath)); - } - - public void OnDisable() - { - new InputComponentEditorAnalytic(InputSystemComponent.OnScreenButton).Send(); - } - - public override void OnInspectorGUI() - { - // Current implementation has UGUI dependencies (ISXB-915, ISXB-916) - UGUIOnScreenControlEditorUtils.ShowWarningIfNotPartOfCanvasHierarchy((OnScreenButton)target); - - UnityEditor.EditorGUILayout.PropertyField(m_ControlPathInternal); + #if UNITY_EDITOR + static internal class OnScreenButtonEditorHelper { + static internal string m_ControlPath = nameof(OnScreenButton.m_ControlPath); + } + #endif - serializedObject.ApplyModifiedProperties(); - } - } -#endif } } #endif diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs index 25920c27c2..b252a79c7b 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs @@ -371,7 +371,7 @@ private void DrawGizmoCircle(Vector2 center, float radius) } } - private void UpdateDynamicOriginClickableArea() + internal void UpdateDynamicOriginClickableArea() { var dynamicOriginTransform = transform.Find(kDynamicOriginClickable); if (dynamicOriginTransform) @@ -515,82 +515,19 @@ public enum Behaviour ExactPositionWithDynamicOrigin } -#if UNITY_EDITOR - [CustomEditor(typeof(OnScreenStick))] - internal class OnScreenStickEditor : UnityEditor.Editor - { - private AnimBool m_ShowDynamicOriginOptions; - private AnimBool m_ShowIsolatedInputActions; - - private SerializedProperty m_UseIsolatedInputActions; - private SerializedProperty m_Behaviour; - private SerializedProperty m_ControlPathInternal; - private SerializedProperty m_MovementRange; - private SerializedProperty m_DynamicOriginRange; - private SerializedProperty m_PointerDownAction; - private SerializedProperty m_PointerMoveAction; - - public void OnEnable() - { - m_ShowDynamicOriginOptions = new AnimBool(false); - m_ShowIsolatedInputActions = new AnimBool(false); - - m_UseIsolatedInputActions = serializedObject.FindProperty(nameof(OnScreenStick.m_UseIsolatedInputActions)); - - m_Behaviour = serializedObject.FindProperty(nameof(OnScreenStick.m_Behaviour)); - m_ControlPathInternal = serializedObject.FindProperty(nameof(OnScreenStick.m_ControlPath)); - m_MovementRange = serializedObject.FindProperty(nameof(OnScreenStick.m_MovementRange)); - m_DynamicOriginRange = serializedObject.FindProperty(nameof(OnScreenStick.m_DynamicOriginRange)); - m_PointerDownAction = serializedObject.FindProperty(nameof(OnScreenStick.m_PointerDownAction)); - m_PointerMoveAction = serializedObject.FindProperty(nameof(OnScreenStick.m_PointerMoveAction)); - } - - public void OnDisable() - { - // Report analytics - new InputComponentEditorAnalytic(InputSystemComponent.OnScreenStick).Send(); - new OnScreenStickEditorAnalytic(this).Send(); - } - - public override void OnInspectorGUI() - { - // Current implementation has UGUI dependencies (ISXB-915, ISXB-916) - UGUIOnScreenControlEditorUtils.ShowWarningIfNotPartOfCanvasHierarchy((OnScreenStick)target); - - EditorGUILayout.PropertyField(m_MovementRange); - EditorGUILayout.PropertyField(m_ControlPathInternal); - EditorGUILayout.PropertyField(m_Behaviour); - - m_ShowDynamicOriginOptions.target = ((OnScreenStick)target).behaviour == - Behaviour.ExactPositionWithDynamicOrigin; - if (EditorGUILayout.BeginFadeGroup(m_ShowDynamicOriginOptions.faded)) - { - EditorGUI.indentLevel++; - EditorGUI.BeginChangeCheck(); - EditorGUILayout.PropertyField(m_DynamicOriginRange); - if (EditorGUI.EndChangeCheck()) - { - ((OnScreenStick)target).UpdateDynamicOriginClickableArea(); - } - EditorGUI.indentLevel--; - } - EditorGUILayout.EndFadeGroup(); - - EditorGUILayout.PropertyField(m_UseIsolatedInputActions); - m_ShowIsolatedInputActions.target = m_UseIsolatedInputActions.boolValue; - if (EditorGUILayout.BeginFadeGroup(m_ShowIsolatedInputActions.faded)) - { - EditorGUI.indentLevel++; - EditorGUILayout.PropertyField(m_PointerDownAction); - EditorGUILayout.PropertyField(m_PointerMoveAction); - EditorGUI.indentLevel--; - } - EditorGUILayout.EndFadeGroup(); - - serializedObject.ApplyModifiedProperties(); - } + #if UNITY_EDITOR + static internal class OnScreenStickEditorHelper { + internal static string m_UseIsolatedInputActions = nameof(OnScreenStick.m_UseIsolatedInputActions); + internal static string m_Behaviour = nameof(OnScreenStick.m_Behaviour); + internal static string m_ControlPath = nameof(OnScreenStick.m_ControlPath); + internal static string m_MovementRange = nameof(OnScreenStick.m_MovementRange); + internal static string m_DynamicOriginRange = nameof(OnScreenStick.m_DynamicOriginRange); + internal static string m_PointerDownAction = nameof(OnScreenStick.m_PointerDownAction); + internal static string m_PointerMoveAction = nameof(OnScreenStick.m_PointerMoveAction); } -#endif + #endif + } + } #endif diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs index 756e192e88..ed00dc630e 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs @@ -7,9 +7,6 @@ using UnityEngine.InputSystem.Utilities; using UnityEngine.Serialization; using UnityEngine.UI; -#if UNITY_EDITOR -using UnityEditor; -#endif ////FIXME: The UI is currently not reacting to pointers until they are moved after the UI module has been enabled. What needs to //// happen is that point, trackedDevicePosition, and trackedDeviceOrientation have initial state checks. However, for touch, @@ -1609,18 +1606,13 @@ public InputActionReference trackedDeviceSelect } #if UNITY_EDITOR + internal static Action m_Reset; /// protected override void Reset() { base.Reset(); - - var asset = (InputActionAsset)AssetDatabase.LoadAssetAtPath( - UnityEngine.InputSystem.Editor.PlayerInputEditor.kDefaultInputActionsAssetPath, - typeof(InputActionAsset)); - // Setting default asset and actions when creating via inspector - Editor.InputSystemUIInputModuleEditor.ReassignActions(this, asset); + m_Reset.Invoke(this); } - #endif /// diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/VirtualMouseInput.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/VirtualMouseInput.cs index cb8aea5535..7d0c678f67 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/VirtualMouseInput.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/UI/VirtualMouseInput.cs @@ -1,5 +1,6 @@ #if PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI using System; +using UnityEngine.InputSystem; using UnityEngine.InputSystem.LowLevel; using UnityEngine.UI; @@ -613,17 +614,7 @@ public enum CursorMode HardwareCursorIfAvailable, } - #if UNITY_EDITOR - [UnityEditor.CustomEditor(typeof(VirtualMouseInput))] - private class VirtualMouseInputEditor : UnityEditor.Editor - { - public void OnDisable() - { - new InputComponentEditorAnalytic(InputSystemComponent.VirtualMouseInput).Send(); - new VirtualMouseInputEditorAnalytic(this).Send(); - } - } - #endif + } } #endif // PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI From cbf236a1761b9487b89e5ab35e0a4755bdec1b60 Mon Sep 17 00:00:00 2001 From: leonardo Date: Sat, 10 May 2025 02:50:42 +0200 Subject: [PATCH 6/6] fix compilation on unity versions older than 2023.2 --- Packages/com.unity.inputsystem/InputSystem/InputAnalytics.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/InputAnalytics.cs b/Packages/com.unity.inputsystem/InputSystem/InputAnalytics.cs index e7dbaf354a..51112ec00e 100644 --- a/Packages/com.unity.inputsystem/InputSystem/InputAnalytics.cs +++ b/Packages/com.unity.inputsystem/InputSystem/InputAnalytics.cs @@ -140,9 +140,12 @@ public StartupEventAnalytic(InputManager manager) public InputAnalyticInfo info => new InputAnalyticInfo(kEventName, kMaxEventsPerHour, kMaxNumberOfElements); -#if UNITY_EDITOR && UNITY_2023_2_OR_NEWER +#if UNITY_EDITOR internal static Func m_EditorPlayerSettingHelpersGetNewSystemBackendsEnabled; internal static Func m_EditorPlayerSettingHelpersGetOldSystemBackendsEnabled; +#endif + +#if UNITY_EDITOR && UNITY_2023_2_OR_NEWER public bool TryGatherData(out UnityEngine.Analytics.IAnalytic.IData data, out Exception error) #else public bool TryGatherData(out IInputAnalyticData data, out Exception error)