Skip to content

Commit e80dda7

Browse files
authored
CHANGE: Moved UI to be an optional dependency. (#1113)
Remove hard dependency on UI and added compiler defines for UI, Physics and Physics2D.
1 parent 3aa395f commit e80dda7

19 files changed

+77
-25
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ however, it has to be formatted properly to pass verification tests.
1414
- `VirtualMouseInput` not moving the software cursor when set to `HardwareCursorIsAvailable` but not having a hardware cursor ()
1515
- Can now override built-in Android gamepad layouts. Previously, the input system would always choose its default defaults even after registering more specific layouts using `InputSystem.RegisterLayout`.
1616
- `InputControlPath.TryGetControlLayout` no longer throws `NotImplementedException` for `<Mouse>/scroll/x` and similar paths where the layout is modifying a control it inherited from its base layout ([thread](https://forum.unity.com/threads/notimplementedexception-when-using-inputcontrolpath-trygetcontrollayout-on-mouse-controls.847129/)).
17-
- Fixed compilation errors when disabling built-in VR and XR packages. ([case 1214248](https://issuetracker.unity3d.com/issues/enable-input-system-symbol-is-not-being-updated-when-the-input-system-is-changed-in-player-settings/)).
17+
- Fixed compilation errors when disabling built-in VR and XR modules. ([case 1214248](https://issuetracker.unity3d.com/issues/enable-input-system-symbol-is-not-being-updated-when-the-input-system-is-changed-in-player-settings/)).
18+
- Fixed compilation errors when disabling built-in Physics and Physics2D modules. ([case 1191392](https://issuetracker.unity3d.com/issues/inputsystem-trackeddeviceraycaster-has-hard-references-on-both-physics-and-physics2d)).
1819
- No longer throws `NotImplementedException` when matching against a field of `InputDeviceDescription.capabilities` when the value of the field used scientific notation.
1920
- No longer incorrectly matches fields of `InputDeviceDescription.capabilities` by prefix only (i.e. previously it would find the field "foo" when actually looking for "foobar").
2021

@@ -39,6 +40,7 @@ however, it has to be formatted properly to pass verification tests.
3940

4041
- `InputDevice.all` has been deprecated due to the confusion it creates with other getters like `Gamepad.all`. Use `InputSystem.devices` instead ([case 1231216](https://issuetracker.unity3d.com/issues/joystick-dot-all-lists-more-than-just-joysticks)).
4142
* In the same vein, we added a new `Joystick.all` getter that works the same as `Gamepad.all`.
43+
- Changed UI Package to be optional dependency. Removing the package will now disable all UI relevant Input code.
4244

4345
## [1.0.0-preview.6] - 2020-03-06
4446

Packages/com.unity.inputsystem/InputSystem/Controls/InputControlExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using Unity.Collections.LowLevel.Unsafe;
66
using UnityEngine.InputSystem.Controls;
77
using UnityEngine.InputSystem.LowLevel;
8-
using UnityEngine.InputSystem.UI;
98
using UnityEngine.InputSystem.Utilities;
109

1110
////REVIEW: some of the stuff here is really low-level; should we move it into a separate static class inside of .LowLevel?

Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI
12
using UnityEngine.EventSystems;
23
using UnityEngine.InputSystem.Layouts;
34

@@ -44,3 +45,4 @@ protected override string controlPathInternal
4445
}
4546
}
4647
}
48+
#endif

Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI
12
using UnityEngine.EventSystems;
23
using UnityEngine.Serialization;
34
using UnityEngine.InputSystem.Layouts;
@@ -71,3 +72,4 @@ protected override string controlPathInternal
7172
}
7273
}
7374
}
75+
#endif

Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInput.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
using System.Collections.Generic;
33
using UnityEngine.Events;
44
using UnityEngine.InputSystem.LowLevel;
5-
using UnityEngine.InputSystem.UI;
65
using UnityEngine.InputSystem.Users;
76
using UnityEngine.InputSystem.Utilities;
87

8+
#if PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI
9+
using UnityEngine.InputSystem.UI;
10+
#endif
11+
912
////TODO: allow PlayerInput to be set up in a way where it's in an unpaired/non-functional state and expects additional configuration
1013

1114
////REVIEW: having everything coupled to component enable/disable is quite restrictive; can we allow PlayerInputs
@@ -40,7 +43,7 @@ namespace UnityEngine.InputSystem
4043
/// <remarks>
4144
/// PlayerInput is a high-level wrapper around much of the input system's functionality
4245
/// which is meant to help getting set up with the new input system quickly. It takes
43-
/// care of <see cref="InputAction"/> bookkeeping and has a custom UI to help
46+
/// care of <see cref="InputAction"/> bookkeeping and has a custom UI(requires the "Unity UI" package) to help
4447
/// setting up input.
4548
///
4649
/// The component supports local multiplayer implicitly. Each PlayerInput instance
@@ -49,8 +52,8 @@ namespace UnityEngine.InputSystem
4952
/// <see cref="UnityEngine.InputSystem.PlayerInputManager"/>.
5053
///
5154
/// The way PlayerInput notifies script code of events is determined by <see cref="notificationBehavior"/>.
52-
/// By default, this is set to <see cref="UnityEngine.InputSystem.PlayerNotifications.SendMessages"/> which will use <see
53-
/// cref="GameObject.SendMessage(string,object)"/> to send messages to the <see cref="GameObject"/>
55+
/// By default, this is set to <see cref="UnityEngine.InputSystem.PlayerNotifications.SendMessages"/> which will use
56+
/// <see cref="GameObject.SendMessage(string,object)"/> to send messages to the <see cref="GameObject"/>
5457
/// that PlayerInput sits on.
5558
///
5659
/// <example>
@@ -173,8 +176,8 @@ namespace UnityEngine.InputSystem
173176
///
174177
/// Device pairings can be changed at any time by either manually controlling pairing through
175178
/// <see cref="InputUser.PerformPairingWithDevice"/> (and related methods) using a PlayerInput's
176-
/// assigned <see cref="user"/> or by switching control schemes (e.g. using <see
177-
/// cref="SwitchCurrentControlScheme(string,InputDevice[])"/>), if any are present in the PlayerInput's
179+
/// assigned <see cref="user"/> or by switching control schemes (e.g. using
180+
/// <see cref="SwitchCurrentControlScheme(string,InputDevice[])"/>), if any are present in the PlayerInput's
178181
/// <see cref="actions"/>.
179182
///
180183
/// When a player loses a device paired to it (e.g. when it is unplugged or loses power), <see cref="InputUser"/>
@@ -184,8 +187,8 @@ namespace UnityEngine.InputSystem
184187
/// which also is surfaced as a message, as <see cref="deviceRegainedEvent"/>, or <see cref="onDeviceRegained"/>
185188
/// (depending on <see cref="notificationBehavior"/>).
186189
///
187-
/// When there is only a single active PlayerInput in the game, joining is not enabled (see <see
188-
/// cref="PlayerInputManager.joiningEnabled"/>), and <see cref="neverAutoSwitchControlSchemes"/> is not
190+
/// When there is only a single active PlayerInput in the game, joining is not enabled (see
191+
/// <see cref="PlayerInputManager.joiningEnabled"/>), and <see cref="neverAutoSwitchControlSchemes"/> is not
189192
/// set to <c>true</c>, device pairings for the player will also update automatically based on device usage.
190193
///
191194
/// If control schemes are present in <see cref="actions"/>, then if a device is used (not merely plugged in
@@ -708,6 +711,7 @@ Camera camera
708711
set => m_Camera = value;
709712
}
710713

714+
#if PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI
711715
/// <summary>
712716
/// UI InputModule that should have it's input actions synchronized to this PlayerInput's actions.
713717
/// </summary>
@@ -728,6 +732,7 @@ public InputSystemUIInputModule uiInputModule
728732
m_UIInputModule.actionsAsset = m_Actions;
729733
}
730734
}
735+
#endif
731736

732737
/// <summary>
733738
/// The internal user tied to the player.
@@ -1054,8 +1059,12 @@ private static PlayerInput DoInstantiate(GameObject prefab)
10541059
[Tooltip("Determine how notifications should be sent when an input-related event associated with the player happens.")]
10551060
[SerializeField] internal PlayerNotifications m_NotificationBehavior;
10561061
[Tooltip("UI InputModule that should have it's input actions synchronized to this PlayerInput's actions.")]
1062+
1063+
#if UNITY_INPUT_SYSTEM_ENABLE_UI
10571064
[SerializeField] internal InputSystemUIInputModule m_UIInputModule;
10581065
[Tooltip("Event that is triggered when the PlayerInput loses a paired device (e.g. its battery runs out).")]
1066+
#endif
1067+
10591068
[SerializeField] internal DeviceLostEvent m_DeviceLostEvent;
10601069
[SerializeField] internal DeviceRegainedEvent m_DeviceRegainedEvent;
10611070
[SerializeField] internal ControlsChangedEvent m_ControlsChangedEvent;
@@ -1127,8 +1136,10 @@ private void InitializeActions()
11271136
break;
11281137
}
11291138

1139+
#if UNITY_INPUT_SYSTEM_ENABLE_UI
11301140
if (uiInputModule != null)
11311141
uiInputModule.actionsAsset = m_Actions;
1142+
#endif
11321143

11331144
switch (m_NotificationBehavior)
11341145
{

Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputEditor.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
using System.Linq;
66
using System.Text;
77
using UnityEditor;
8-
using UnityEngine.InputSystem.UI;
9-
using UnityEngine.InputSystem.UI.Editor;
108
using UnityEngine.InputSystem.Users;
119
using UnityEngine.InputSystem.Utilities;
1210

11+
#if UNITY_INPUT_SYSTEM_ENABLE_UI
12+
using UnityEngine.InputSystem.UI;
13+
using UnityEngine.InputSystem.UI.Editor;
14+
#endif
15+
1316
////TODO: detect if new input system isn't enabled and provide UI to enable it
1417
#pragma warning disable 0414
1518
namespace UnityEngine.InputSystem.Editor
@@ -33,13 +36,16 @@ public void OnEnable()
3336
m_DefaultControlSchemeProperty = serializedObject.FindProperty("m_DefaultControlScheme");
3437
m_NeverAutoSwitchControlSchemesProperty = serializedObject.FindProperty("m_NeverAutoSwitchControlSchemes");
3538
m_DefaultActionMapProperty = serializedObject.FindProperty("m_DefaultActionMap");
36-
m_UIInputModuleProperty = serializedObject.FindProperty("m_UIInputModule");
3739
m_NotificationBehaviorProperty = serializedObject.FindProperty("m_NotificationBehavior");
3840
m_CameraProperty = serializedObject.FindProperty("m_Camera");
3941
m_ActionEventsProperty = serializedObject.FindProperty("m_ActionEvents");
4042
m_DeviceLostEventProperty = serializedObject.FindProperty("m_DeviceLostEvent");
4143
m_DeviceRegainedEventProperty = serializedObject.FindProperty("m_DeviceRegainedEvent");
4244
m_ControlsChangedEventProperty = serializedObject.FindProperty("m_ControlsChangedEvent");
45+
46+
#if UNITY_INPUT_SYSTEM_ENABLE_UI
47+
m_UIInputModuleProperty = serializedObject.FindProperty("m_UIInputModule");
48+
#endif
4349
}
4450

4551
public void OnDestroy()
@@ -124,6 +130,7 @@ public override void OnInspectorGUI()
124130
--EditorGUI.indentLevel;
125131
DoHelpCreateAssetUI();
126132

133+
#if UNITY_INPUT_SYSTEM_ENABLE_UI
127134
// UI config section.
128135
if (m_UIPropertyText == null)
129136
m_UIPropertyText = EditorGUIUtility.TrTextContent("UI Input Module", m_UIInputModuleProperty.tooltip);
@@ -137,11 +144,12 @@ public override void OnInspectorGUI()
137144
var uiModule = m_UIInputModuleProperty.objectReferenceValue as InputSystemUIInputModule;
138145
if (m_ActionsProperty.objectReferenceValue != null && uiModule.actionsAsset != m_ActionsProperty.objectReferenceValue)
139146
{
140-
EditorGUILayout.HelpBox("The referenced InputSystemUIInputModule is configured using differnet input actions then this PlayerInput. They should match if you want to synchronize PlayerInput actions to the UI input.", MessageType.Warning);
147+
EditorGUILayout.HelpBox("The referenced InputSystemUIInputModule is configured using different input actions then this PlayerInput. They should match if you want to synchronize PlayerInput actions to the UI input.", MessageType.Warning);
141148
if (GUILayout.Button(m_FixInputModuleText))
142149
InputSystemUIInputModuleEditor.ReassignActions(uiModule, m_ActionsProperty.objectReferenceValue as InputActionAsset);
143150
}
144151
}
152+
#endif
145153

146154
// Camera section.
147155
if (m_CameraPropertyText == null)
@@ -546,7 +554,9 @@ void AddEntry(InputAction action, PlayerInput.ActionEvent actionEvent)
546554
[NonSerialized] private SerializedProperty m_DefaultActionMapProperty;
547555
[NonSerialized] private SerializedProperty m_NeverAutoSwitchControlSchemesProperty;
548556
[NonSerialized] private SerializedProperty m_NotificationBehaviorProperty;
557+
#if UNITY_INPUT_SYSTEM_ENABLE_UI
549558
[NonSerialized] private SerializedProperty m_UIInputModuleProperty;
559+
#endif
550560
[NonSerialized] private SerializedProperty m_ActionEventsProperty;
551561
[NonSerialized] private SerializedProperty m_CameraProperty;
552562
[NonSerialized] private SerializedProperty m_DeviceLostEventProperty;

Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using UnityEngine.InputSystem.LowLevel;
55
using UnityEngine.InputSystem.Users;
66
using UnityEngine.InputSystem.Utilities;
7-
using UnityEngine.UI;
87

98
////REVIEW: should we automatically pool/retain up to maxPlayerCount player instances?
109

Packages/com.unity.inputsystem/InputSystem/Plugins/UI/BaseInputOverride.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if UNITY_INPUT_SYSTEM_ENABLE_UI
12
using UnityEngine.EventSystems;
23

34
namespace UnityEngine.InputSystem.UI
@@ -7,3 +8,4 @@ internal class BaseInputOverride : BaseInput
78
public override string compositionString { get; }
89
}
910
}
11+
#endif

Packages/com.unity.inputsystem/InputSystem/Plugins/UI/ExtendedPointerEventData.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI
12
using System.Text;
23
using UnityEngine.EventSystems;
34
using UnityEngine.InputSystem.Controls;
@@ -162,3 +163,4 @@ public enum UIPointerBehavior
162163
AllPointersAsIs,
163164
}
164165
}
166+
#endif

Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI
12
using System;
23
using UnityEngine.EventSystems;
34
using UnityEngine.InputSystem.Controls;
@@ -1723,3 +1724,4 @@ public InputActionAsset actionsAsset
17231724
private NavigationModel m_NavigationState;
17241725
}
17251726
}
1727+
#endif

0 commit comments

Comments
 (0)