diff --git a/Assets/Samples/InGameHints/InGameHintsActions.cs b/Assets/Samples/InGameHints/InGameHintsActions.cs
index ea4324ebaa..d33f1610de 100644
--- a/Assets/Samples/InGameHints/InGameHintsActions.cs
+++ b/Assets/Samples/InGameHints/InGameHintsActions.cs
@@ -17,73 +17,9 @@
namespace UnityEngine.InputSystem.Samples.InGameHints
{
- ///
- /// Provides programmatic access to , , and instances defined in asset "Assets/Samples/InGameHints/InGameHintsActions.inputactions".
- ///
- ///
- /// This class is source generated and any manual edits will be discarded if the associated asset is reimported or modified.
- ///
- ///
- ///
- /// using namespace UnityEngine;
- /// using UnityEngine.InputSystem;
- ///
- /// // Example of using an InputActionMap named "Player" from a UnityEngine.MonoBehaviour implementing callback interface.
- /// public class Example : MonoBehaviour, MyActions.IPlayerActions
- /// {
- /// private MyActions_Actions m_Actions; // Source code representation of asset.
- /// private MyActions_Actions.PlayerActions m_Player; // Source code representation of action map.
- ///
- /// void Awake()
- /// {
- /// m_Actions = new MyActions_Actions(); // Create asset object.
- /// m_Player = m_Actions.Player; // Extract action map object.
- /// m_Player.AddCallbacks(this); // Register callback interface IPlayerActions.
- /// }
- ///
- /// void OnDestroy()
- /// {
- /// m_Actions.Dispose(); // Destroy asset object.
- /// }
- ///
- /// void OnEnable()
- /// {
- /// m_Player.Enable(); // Enable all actions within map.
- /// }
- ///
- /// void OnDisable()
- /// {
- /// m_Player.Disable(); // Disable all actions within map.
- /// }
- ///
- /// #region Interface implementation of MyActions.IPlayerActions
- ///
- /// // Invoked when "Move" action is either started, performed or canceled.
- /// public void OnMove(InputAction.CallbackContext context)
- /// {
- /// Debug.Log($"OnMove: {context.ReadValue<Vector2>()}");
- /// }
- ///
- /// // Invoked when "Attack" action is either started, performed or canceled.
- /// public void OnAttack(InputAction.CallbackContext context)
- /// {
- /// Debug.Log($"OnAttack: {context.ReadValue<float>()}");
- /// }
- ///
- /// #endregion
- /// }
- ///
- ///
public partial class @InGameHintsActions: IInputActionCollection2, IDisposable
{
- ///
- /// Provides access to the underlying asset instance.
- ///
public InputActionAsset asset { get; }
-
- ///
- /// Constructs a new instance.
- ///
public @InGameHintsActions()
{
asset = InputActionAsset.FromJson(@"{
@@ -341,71 +277,57 @@ public @InGameHintsActions()
UnityEngine.Debug.Assert(!m_Gameplay.enabled, "This will cause a leak and performance issues, InGameHintsActions.Gameplay.Disable() has not been called.");
}
- ///
- /// Destroys this asset and all associated instances.
- ///
public void Dispose()
{
UnityEngine.Object.Destroy(asset);
}
- ///
public InputBinding? bindingMask
{
get => asset.bindingMask;
set => asset.bindingMask = value;
}
- ///
public ReadOnlyArray? devices
{
get => asset.devices;
set => asset.devices = value;
}
- ///
public ReadOnlyArray controlSchemes => asset.controlSchemes;
- ///
public bool Contains(InputAction action)
{
return asset.Contains(action);
}
- ///
public IEnumerator GetEnumerator()
{
return asset.GetEnumerator();
}
- ///
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
- ///
public void Enable()
{
asset.Enable();
}
- ///
public void Disable()
{
asset.Disable();
}
- ///
public IEnumerable bindings => asset.bindings;
- ///
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
{
return asset.FindAction(actionNameOrId, throwIfNotFound);
}
- ///
public int FindBinding(InputBinding bindingMask, out InputAction action)
{
return asset.FindBinding(bindingMask, out action);
@@ -419,59 +341,20 @@ public int FindBinding(InputBinding bindingMask, out InputAction action)
private readonly InputAction m_Gameplay_PickUp;
private readonly InputAction m_Gameplay_Drop;
private readonly InputAction m_Gameplay_Throw;
- ///
- /// Provides access to input actions defined in input action map "Gameplay".
- ///
public struct GameplayActions
{
private @InGameHintsActions m_Wrapper;
-
- ///
- /// Construct a new instance of the input action map wrapper class.
- ///
public GameplayActions(@InGameHintsActions wrapper) { m_Wrapper = wrapper; }
- ///
- /// Provides access to the underlying input action "Gameplay/Move".
- ///
public InputAction @Move => m_Wrapper.m_Gameplay_Move;
- ///
- /// Provides access to the underlying input action "Gameplay/Look".
- ///
public InputAction @Look => m_Wrapper.m_Gameplay_Look;
- ///
- /// Provides access to the underlying input action "Gameplay/PickUp".
- ///
public InputAction @PickUp => m_Wrapper.m_Gameplay_PickUp;
- ///
- /// Provides access to the underlying input action "Gameplay/Drop".
- ///
public InputAction @Drop => m_Wrapper.m_Gameplay_Drop;
- ///
- /// Provides access to the underlying input action "Gameplay/Throw".
- ///
public InputAction @Throw => m_Wrapper.m_Gameplay_Throw;
- ///
- /// Provides access to the underlying input action map instance.
- ///
public InputActionMap Get() { return m_Wrapper.m_Gameplay; }
- ///
public void Enable() { Get().Enable(); }
- ///
public void Disable() { Get().Disable(); }
- ///
public bool enabled => Get().enabled;
- ///
- /// Implicitly converts an to an instance.
- ///
public static implicit operator InputActionMap(GameplayActions set) { return set.Get(); }
- ///
- /// Adds , and callbacks provided via on all input actions contained in this map.
- ///
- /// Callback instance.
- ///
- /// If is null or have already been added this method does nothing.
- ///
- ///
public void AddCallbacks(IGameplayActions instance)
{
if (instance == null || m_Wrapper.m_GameplayActionsCallbackInterfaces.Contains(instance)) return;
@@ -493,13 +376,6 @@ public void AddCallbacks(IGameplayActions instance)
@Throw.canceled += instance.OnThrow;
}
- ///
- /// Removes , and callbacks provided via on all input actions contained in this map.
- ///
- ///
- /// Calling this method when have not previously been registered has no side-effects.
- ///
- ///
private void UnregisterCallbacks(IGameplayActions instance)
{
@Move.started -= instance.OnMove;
@@ -519,25 +395,12 @@ private void UnregisterCallbacks(IGameplayActions instance)
@Throw.canceled -= instance.OnThrow;
}
- ///
- /// Unregisters and unregisters all input action callbacks via .
- ///
- ///
public void RemoveCallbacks(IGameplayActions instance)
{
if (m_Wrapper.m_GameplayActionsCallbackInterfaces.Remove(instance))
UnregisterCallbacks(instance);
}
- ///
- /// Replaces all existing callback instances and previously registered input action callbacks associated with them with callbacks provided via .
- ///
- ///
- /// If is null, calling this method will only unregister all existing callbacks but not register any new callbacks.
- ///
- ///
- ///
- ///
public void SetCallbacks(IGameplayActions instance)
{
foreach (var item in m_Wrapper.m_GameplayActionsCallbackInterfaces)
@@ -546,15 +409,8 @@ public void SetCallbacks(IGameplayActions instance)
AddCallbacks(instance);
}
}
- ///
- /// Provides a new instance referencing this action map.
- ///
public GameplayActions @Gameplay => new GameplayActions(this);
private int m_GamepadSchemeIndex = -1;
- ///
- /// Provides access to the input control scheme.
- ///
- ///
public InputControlScheme GamepadScheme
{
get
@@ -564,10 +420,6 @@ public InputControlScheme GamepadScheme
}
}
private int m_KeyboardMouseSchemeIndex = -1;
- ///
- /// Provides access to the input control scheme.
- ///
- ///
public InputControlScheme KeyboardMouseScheme
{
get
@@ -576,47 +428,12 @@ public InputControlScheme KeyboardMouseScheme
return asset.controlSchemes[m_KeyboardMouseSchemeIndex];
}
}
- ///
- /// Interface to implement callback methods for all input action callbacks associated with input actions defined by "Gameplay" which allows adding and removing callbacks.
- ///
- ///
- ///
public interface IGameplayActions
{
- ///
- /// Method invoked when associated input action "Move" is either , or .
- ///
- ///
- ///
- ///
void OnMove(InputAction.CallbackContext context);
- ///
- /// Method invoked when associated input action "Look" is either , or .
- ///
- ///
- ///
- ///
void OnLook(InputAction.CallbackContext context);
- ///
- /// Method invoked when associated input action "PickUp" is either , or .
- ///
- ///
- ///
- ///
void OnPickUp(InputAction.CallbackContext context);
- ///
- /// Method invoked when associated input action "Drop" is either , or .
- ///
- ///
- ///
- ///
void OnDrop(InputAction.CallbackContext context);
- ///
- /// Method invoked when associated input action "Throw" is either , or .
- ///
- ///
- ///
- ///
void OnThrow(InputAction.CallbackContext context);
}
}
diff --git a/Assets/Tests/InputSystem/InputActionCodeGeneratorActions.cs b/Assets/Tests/InputSystem/InputActionCodeGeneratorActions.cs
index 2b4f542eac..45dab88203 100644
--- a/Assets/Tests/InputSystem/InputActionCodeGeneratorActions.cs
+++ b/Assets/Tests/InputSystem/InputActionCodeGeneratorActions.cs
@@ -15,73 +15,9 @@
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
-///
-/// Provides programmatic access to , , and instances defined in asset "Assets/Tests/InputSystem/InputActionCodeGeneratorActions.inputactions".
-///
-///
-/// This class is source generated and any manual edits will be discarded if the associated asset is reimported or modified.
-///
-///
-///
-/// using namespace UnityEngine;
-/// using UnityEngine.InputSystem;
-///
-/// // Example of using an InputActionMap named "Player" from a UnityEngine.MonoBehaviour implementing callback interface.
-/// public class Example : MonoBehaviour, MyActions.IPlayerActions
-/// {
-/// private MyActions_Actions m_Actions; // Source code representation of asset.
-/// private MyActions_Actions.PlayerActions m_Player; // Source code representation of action map.
-///
-/// void Awake()
-/// {
-/// m_Actions = new MyActions_Actions(); // Create asset object.
-/// m_Player = m_Actions.Player; // Extract action map object.
-/// m_Player.AddCallbacks(this); // Register callback interface IPlayerActions.
-/// }
-///
-/// void OnDestroy()
-/// {
-/// m_Actions.Dispose(); // Destroy asset object.
-/// }
-///
-/// void OnEnable()
-/// {
-/// m_Player.Enable(); // Enable all actions within map.
-/// }
-///
-/// void OnDisable()
-/// {
-/// m_Player.Disable(); // Disable all actions within map.
-/// }
-///
-/// #region Interface implementation of MyActions.IPlayerActions
-///
-/// // Invoked when "Move" action is either started, performed or canceled.
-/// public void OnMove(InputAction.CallbackContext context)
-/// {
-/// Debug.Log($"OnMove: {context.ReadValue<Vector2>()}");
-/// }
-///
-/// // Invoked when "Attack" action is either started, performed or canceled.
-/// public void OnAttack(InputAction.CallbackContext context)
-/// {
-/// Debug.Log($"OnAttack: {context.ReadValue<float>()}");
-/// }
-///
-/// #endregion
-/// }
-///
-///
public partial class @InputActionCodeGeneratorActions: IInputActionCollection2, IDisposable
{
- ///
- /// Provides access to the underlying asset instance.
- ///
public InputActionAsset asset { get; }
-
- ///
- /// Constructs a new instance.
- ///
public @InputActionCodeGeneratorActions()
{
asset = InputActionAsset.FromJson(@"{
@@ -149,71 +85,57 @@ public @InputActionCodeGeneratorActions()
UnityEngine.Debug.Assert(!m_gameplay.enabled, "This will cause a leak and performance issues, InputActionCodeGeneratorActions.gameplay.Disable() has not been called.");
}
- ///
- /// Destroys this asset and all associated instances.
- ///
public void Dispose()
{
UnityEngine.Object.Destroy(asset);
}
- ///
public InputBinding? bindingMask
{
get => asset.bindingMask;
set => asset.bindingMask = value;
}
- ///
public ReadOnlyArray? devices
{
get => asset.devices;
set => asset.devices = value;
}
- ///
public ReadOnlyArray controlSchemes => asset.controlSchemes;
- ///
public bool Contains(InputAction action)
{
return asset.Contains(action);
}
- ///
public IEnumerator GetEnumerator()
{
return asset.GetEnumerator();
}
- ///
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
- ///
public void Enable()
{
asset.Enable();
}
- ///
public void Disable()
{
asset.Disable();
}
- ///
public IEnumerable bindings => asset.bindings;
- ///
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
{
return asset.FindAction(actionNameOrId, throwIfNotFound);
}
- ///
public int FindBinding(InputBinding bindingMask, out InputAction action)
{
return asset.FindBinding(bindingMask, out action);
@@ -224,47 +146,17 @@ public int FindBinding(InputBinding bindingMask, out InputAction action)
private List m_GameplayActionsCallbackInterfaces = new List();
private readonly InputAction m_gameplay_action1;
private readonly InputAction m_gameplay_action2;
- ///
- /// Provides access to input actions defined in input action map "gameplay".
- ///
public struct GameplayActions
{
private @InputActionCodeGeneratorActions m_Wrapper;
-
- ///
- /// Construct a new instance of the input action map wrapper class.
- ///
public GameplayActions(@InputActionCodeGeneratorActions wrapper) { m_Wrapper = wrapper; }
- ///
- /// Provides access to the underlying input action "gameplay/action1".
- ///
public InputAction @action1 => m_Wrapper.m_gameplay_action1;
- ///
- /// Provides access to the underlying input action "gameplay/action2".
- ///
public InputAction @action2 => m_Wrapper.m_gameplay_action2;
- ///
- /// Provides access to the underlying input action map instance.
- ///
public InputActionMap Get() { return m_Wrapper.m_gameplay; }
- ///
public void Enable() { Get().Enable(); }
- ///
public void Disable() { Get().Disable(); }
- ///
public bool enabled => Get().enabled;
- ///
- /// Implicitly converts an to an instance.
- ///
public static implicit operator InputActionMap(GameplayActions set) { return set.Get(); }
- ///
- /// Adds , and callbacks provided via on all input actions contained in this map.
- ///
- /// Callback instance.
- ///
- /// If is null or have already been added this method does nothing.
- ///
- ///
public void AddCallbacks(IGameplayActions instance)
{
if (instance == null || m_Wrapper.m_GameplayActionsCallbackInterfaces.Contains(instance)) return;
@@ -277,13 +169,6 @@ public void AddCallbacks(IGameplayActions instance)
@action2.canceled += instance.OnAction2;
}
- ///
- /// Removes , and callbacks provided via on all input actions contained in this map.
- ///
- ///
- /// Calling this method when have not previously been registered has no side-effects.
- ///
- ///
private void UnregisterCallbacks(IGameplayActions instance)
{
@action1.started -= instance.OnAction1;
@@ -294,25 +179,12 @@ private void UnregisterCallbacks(IGameplayActions instance)
@action2.canceled -= instance.OnAction2;
}
- ///
- /// Unregisters and unregisters all input action callbacks via .
- ///
- ///
public void RemoveCallbacks(IGameplayActions instance)
{
if (m_Wrapper.m_GameplayActionsCallbackInterfaces.Remove(instance))
UnregisterCallbacks(instance);
}
- ///
- /// Replaces all existing callback instances and previously registered input action callbacks associated with them with callbacks provided via .
- ///
- ///
- /// If is null, calling this method will only unregister all existing callbacks but not register any new callbacks.
- ///
- ///
- ///
- ///
public void SetCallbacks(IGameplayActions instance)
{
foreach (var item in m_Wrapper.m_GameplayActionsCallbackInterfaces)
@@ -321,30 +193,10 @@ public void SetCallbacks(IGameplayActions instance)
AddCallbacks(instance);
}
}
- ///
- /// Provides a new instance referencing this action map.
- ///
public GameplayActions @gameplay => new GameplayActions(this);
- ///
- /// Interface to implement callback methods for all input action callbacks associated with input actions defined by "gameplay" which allows adding and removing callbacks.
- ///
- ///
- ///
public interface IGameplayActions
{
- ///
- /// Method invoked when associated input action "action1" is either , or .
- ///
- ///
- ///
- ///
void OnAction1(InputAction.CallbackContext context);
- ///
- /// Method invoked when associated input action "action2" is either , or .
- ///
- ///
- ///
- ///
void OnAction2(InputAction.CallbackContext context);
}
}
diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporter.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporter.cs
index 6aa8af8a3a..8abc9b5971 100644
--- a/Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporter.cs
+++ b/Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporter.cs
@@ -256,11 +256,11 @@ private static void GenerateWrapperCode(AssetImportContext ctx, InputActionAsset
if (InputActionCodeGenerator.GenerateWrapperCode(wrapperFilePath, asset, options))
{
- // When we generate the wrapper code cs file during asset import, we cannot call ImportAsset on that directly because
- // script assets have to be imported before all other assets, and are not allowed to be added to the import queue during
- // asset import. So instead we register a callback to trigger a delayed asset refresh which should then pick up the
- // changed/added script, and trigger a new import.
- EditorApplication.delayCall += AssetDatabase.Refresh;
+ // This isn't ideal and may have side effects, but we cannot avoid compiling again.
+ // Previously we attempted to run a EditorApplication.delayCall += AssetDatabase.Refresh
+ // but this would lead to "error: Error building Player because scripts are compiling" in CI.
+ // Previous comment here warned against not being able to reimport here directly, but it seems it's ok.
+ AssetDatabase.ImportAsset(wrapperFilePath);
}
}