Swapping input systems and using a class called InputData to store player's input
This commit is contained in:
743
Assets/InputConfig.cs
Normal file
743
Assets/InputConfig.cs
Normal file
@@ -0,0 +1,743 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
|
||||
// version 1.14.2
|
||||
// from Assets/Settings/InputConfig.inputactions
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
/// <summary>
|
||||
/// Provides programmatic access to <see cref="InputActionAsset" />, <see cref="InputActionMap" />, <see cref="InputAction" /> and <see cref="InputControlScheme" /> instances defined in asset "Assets/Settings/InputConfig.inputactions".
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This class is source generated and any manual edits will be discarded if the associated asset is reimported or modified.
|
||||
/// </remarks>
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// 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
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
public partial class @InputConfig: IInputActionCollection2, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to the underlying asset instance.
|
||||
/// </summary>
|
||||
public InputActionAsset asset { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance.
|
||||
/// </summary>
|
||||
public @InputConfig()
|
||||
{
|
||||
asset = InputActionAsset.FromJson(@"{
|
||||
""version"": 1,
|
||||
""name"": ""InputConfig"",
|
||||
""maps"": [
|
||||
{
|
||||
""name"": ""Default"",
|
||||
""id"": ""0625d9c0-43b5-4745-824b-9fda8ba30fee"",
|
||||
""actions"": [
|
||||
{
|
||||
""name"": ""Camera Horizontal"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""c07137df-45a6-4c7f-a7a9-4a0308e41992"",
|
||||
""expectedControlType"": ""Axis"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""Camera Vertical"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""65ba5ae5-0f08-4c90-85ef-ff497cb253b9"",
|
||||
""expectedControlType"": ""Axis"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
}
|
||||
],
|
||||
""bindings"": [
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""9ec96503-2099-45d3-aaf2-cf1475edb473"",
|
||||
""path"": ""<Gamepad>/leftStick/x"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Camera Horizontal"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""1D Axis"",
|
||||
""id"": ""ed76a404-3e05-4d45-a021-05844bc10505"",
|
||||
""path"": ""1DAxis"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Camera Horizontal"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""negative"",
|
||||
""id"": ""d655a04f-766a-439d-901d-794696b1ec89"",
|
||||
""path"": ""<Keyboard>/a"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Camera Horizontal"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""positive"",
|
||||
""id"": ""b0d947fc-bec7-46a7-9704-afc08a1e2886"",
|
||||
""path"": ""<Keyboard>/d"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Camera Horizontal"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""ede8a471-011b-444f-aea7-3079794926f1"",
|
||||
""path"": ""<Gamepad>/leftStick/y"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Camera Vertical"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""1D Axis"",
|
||||
""id"": ""e9f01183-aa1d-4ebf-9799-09aec02d3cf8"",
|
||||
""path"": ""1DAxis"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Camera Vertical"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""negative"",
|
||||
""id"": ""908edb1a-3d82-4454-9d8e-2020aafd0714"",
|
||||
""path"": ""<Keyboard>/s"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Camera Vertical"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""positive"",
|
||||
""id"": ""34639f79-f10f-4950-96dc-b2a5ab43c4a7"",
|
||||
""path"": ""<Keyboard>/w"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Camera Vertical"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""name"": ""Marketing"",
|
||||
""id"": ""56f2eb0a-da06-47a3-9123-f39cfe90e6a1"",
|
||||
""actions"": [
|
||||
{
|
||||
""name"": ""CameraFOV"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""970c903e-bdb9-42ab-b5e5-0e5019ac0994"",
|
||||
""expectedControlType"": ""Axis"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""CameraUpDown"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""ad16855f-155a-4c1c-9557-171868403461"",
|
||||
""expectedControlType"": """",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""CameraRotationX"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""f47fc852-b65d-4ae3-8ee4-c4e948103760"",
|
||||
""expectedControlType"": """",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
},
|
||||
{
|
||||
""name"": ""CameraRotationY"",
|
||||
""type"": ""Value"",
|
||||
""id"": ""54a4cdd3-92f4-4562-bc26-932f1ecf3961"",
|
||||
""expectedControlType"": """",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true
|
||||
}
|
||||
],
|
||||
""bindings"": [
|
||||
{
|
||||
""name"": ""1D Axis"",
|
||||
""id"": ""5b23e3c8-fa10-4d03-81ba-247c869d1e57"",
|
||||
""path"": ""1DAxis"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""CameraFOV"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""negative"",
|
||||
""id"": ""ebd13f12-54ac-4f07-b24b-8794856068a5"",
|
||||
""path"": ""<Keyboard>/o"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""CameraFOV"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""positive"",
|
||||
""id"": ""6e9ad397-b3d9-4b84-ab9c-fc1621b99e13"",
|
||||
""path"": ""<Keyboard>/p"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""CameraFOV"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""c0c2a08a-f7cc-4b85-bfc0-d645d7b3f48f"",
|
||||
""path"": ""<Gamepad>/dpad/x"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""CameraFOV"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""8d66cc2f-effa-47c4-8d9c-f1f89c9fbebc"",
|
||||
""path"": ""<Gamepad>/dpad/y"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""CameraUpDown"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""1D Axis"",
|
||||
""id"": ""77e92290-0b17-41f7-a044-9109ddfb1149"",
|
||||
""path"": ""1DAxis"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""CameraUpDown"",
|
||||
""isComposite"": true,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": ""negative"",
|
||||
""id"": ""1797a6a8-20e6-420a-9623-f49123d9c18a"",
|
||||
""path"": ""<Keyboard>/k"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""CameraUpDown"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": ""positive"",
|
||||
""id"": ""77a25d8f-be60-4403-84a5-b32f4199555b"",
|
||||
""path"": ""<Keyboard>/l"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""CameraUpDown"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""1a68b1f2-634e-47f5-b88c-29be850e1a75"",
|
||||
""path"": ""<Gamepad>/rightStick/x"",
|
||||
""interactions"": """",
|
||||
""processors"": ""Invert"",
|
||||
""groups"": """",
|
||||
""action"": ""CameraRotationX"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""222a9167-cf4e-473e-bcd8-173c4084fa81"",
|
||||
""path"": ""<Gamepad>/rightStick/y"",
|
||||
""interactions"": """",
|
||||
""processors"": ""Invert"",
|
||||
""groups"": """",
|
||||
""action"": ""CameraRotationY"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
""controlSchemes"": []
|
||||
}");
|
||||
// Default
|
||||
m_Default = asset.FindActionMap("Default", throwIfNotFound: true);
|
||||
m_Default_CameraHorizontal = m_Default.FindAction("Camera Horizontal", throwIfNotFound: true);
|
||||
m_Default_CameraVertical = m_Default.FindAction("Camera Vertical", throwIfNotFound: true);
|
||||
// Marketing
|
||||
m_Marketing = asset.FindActionMap("Marketing", throwIfNotFound: true);
|
||||
m_Marketing_CameraFOV = m_Marketing.FindAction("CameraFOV", throwIfNotFound: true);
|
||||
m_Marketing_CameraUpDown = m_Marketing.FindAction("CameraUpDown", throwIfNotFound: true);
|
||||
m_Marketing_CameraRotationX = m_Marketing.FindAction("CameraRotationX", throwIfNotFound: true);
|
||||
m_Marketing_CameraRotationY = m_Marketing.FindAction("CameraRotationY", throwIfNotFound: true);
|
||||
}
|
||||
|
||||
~@InputConfig()
|
||||
{
|
||||
UnityEngine.Debug.Assert(!m_Default.enabled, "This will cause a leak and performance issues, InputConfig.Default.Disable() has not been called.");
|
||||
UnityEngine.Debug.Assert(!m_Marketing.enabled, "This will cause a leak and performance issues, InputConfig.Marketing.Disable() has not been called.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Destroys this asset and all associated <see cref="InputAction"/> instances.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
UnityEngine.Object.Destroy(asset);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.bindingMask" />
|
||||
public InputBinding? bindingMask
|
||||
{
|
||||
get => asset.bindingMask;
|
||||
set => asset.bindingMask = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.devices" />
|
||||
public ReadOnlyArray<InputDevice>? devices
|
||||
{
|
||||
get => asset.devices;
|
||||
set => asset.devices = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.controlSchemes" />
|
||||
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.Contains(InputAction)" />
|
||||
public bool Contains(InputAction action)
|
||||
{
|
||||
return asset.Contains(action);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.GetEnumerator()" />
|
||||
public IEnumerator<InputAction> GetEnumerator()
|
||||
{
|
||||
return asset.GetEnumerator();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IEnumerable.GetEnumerator()" />
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.Enable()" />
|
||||
public void Enable()
|
||||
{
|
||||
asset.Enable();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.Disable()" />
|
||||
public void Disable()
|
||||
{
|
||||
asset.Disable();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.bindings" />
|
||||
public IEnumerable<InputBinding> bindings => asset.bindings;
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.FindAction(string, bool)" />
|
||||
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
|
||||
{
|
||||
return asset.FindAction(actionNameOrId, throwIfNotFound);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionAsset.FindBinding(InputBinding, out InputAction)" />
|
||||
public int FindBinding(InputBinding bindingMask, out InputAction action)
|
||||
{
|
||||
return asset.FindBinding(bindingMask, out action);
|
||||
}
|
||||
|
||||
// Default
|
||||
private readonly InputActionMap m_Default;
|
||||
private List<IDefaultActions> m_DefaultActionsCallbackInterfaces = new List<IDefaultActions>();
|
||||
private readonly InputAction m_Default_CameraHorizontal;
|
||||
private readonly InputAction m_Default_CameraVertical;
|
||||
/// <summary>
|
||||
/// Provides access to input actions defined in input action map "Default".
|
||||
/// </summary>
|
||||
public struct DefaultActions
|
||||
{
|
||||
private @InputConfig m_Wrapper;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a new instance of the input action map wrapper class.
|
||||
/// </summary>
|
||||
public DefaultActions(@InputConfig wrapper) { m_Wrapper = wrapper; }
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action "Default/CameraHorizontal".
|
||||
/// </summary>
|
||||
public InputAction @CameraHorizontal => m_Wrapper.m_Default_CameraHorizontal;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action "Default/CameraVertical".
|
||||
/// </summary>
|
||||
public InputAction @CameraVertical => m_Wrapper.m_Default_CameraVertical;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action map instance.
|
||||
/// </summary>
|
||||
public InputActionMap Get() { return m_Wrapper.m_Default; }
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.Enable()" />
|
||||
public void Enable() { Get().Enable(); }
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.Disable()" />
|
||||
public void Disable() { Get().Disable(); }
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.enabled" />
|
||||
public bool enabled => Get().enabled;
|
||||
/// <summary>
|
||||
/// Implicitly converts an <see ref="DefaultActions" /> to an <see ref="InputActionMap" /> instance.
|
||||
/// </summary>
|
||||
public static implicit operator InputActionMap(DefaultActions set) { return set.Get(); }
|
||||
/// <summary>
|
||||
/// Adds <see cref="InputAction.started"/>, <see cref="InputAction.performed"/> and <see cref="InputAction.canceled"/> callbacks provided via <param cref="instance" /> on all input actions contained in this map.
|
||||
/// </summary>
|
||||
/// <param name="instance">Callback instance.</param>
|
||||
/// <remarks>
|
||||
/// If <paramref name="instance" /> is <c>null</c> or <paramref name="instance"/> have already been added this method does nothing.
|
||||
/// </remarks>
|
||||
/// <seealso cref="DefaultActions" />
|
||||
public void AddCallbacks(IDefaultActions instance)
|
||||
{
|
||||
if (instance == null || m_Wrapper.m_DefaultActionsCallbackInterfaces.Contains(instance)) return;
|
||||
m_Wrapper.m_DefaultActionsCallbackInterfaces.Add(instance);
|
||||
@CameraHorizontal.started += instance.OnCameraHorizontal;
|
||||
@CameraHorizontal.performed += instance.OnCameraHorizontal;
|
||||
@CameraHorizontal.canceled += instance.OnCameraHorizontal;
|
||||
@CameraVertical.started += instance.OnCameraVertical;
|
||||
@CameraVertical.performed += instance.OnCameraVertical;
|
||||
@CameraVertical.canceled += instance.OnCameraVertical;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes <see cref="InputAction.started"/>, <see cref="InputAction.performed"/> and <see cref="InputAction.canceled"/> callbacks provided via <param cref="instance" /> on all input actions contained in this map.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Calling this method when <paramref name="instance" /> have not previously been registered has no side-effects.
|
||||
/// </remarks>
|
||||
/// <seealso cref="DefaultActions" />
|
||||
private void UnregisterCallbacks(IDefaultActions instance)
|
||||
{
|
||||
@CameraHorizontal.started -= instance.OnCameraHorizontal;
|
||||
@CameraHorizontal.performed -= instance.OnCameraHorizontal;
|
||||
@CameraHorizontal.canceled -= instance.OnCameraHorizontal;
|
||||
@CameraVertical.started -= instance.OnCameraVertical;
|
||||
@CameraVertical.performed -= instance.OnCameraVertical;
|
||||
@CameraVertical.canceled -= instance.OnCameraVertical;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unregisters <param cref="instance" /> and unregisters all input action callbacks via <see cref="DefaultActions.UnregisterCallbacks(IDefaultActions)" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="DefaultActions.UnregisterCallbacks(IDefaultActions)" />
|
||||
public void RemoveCallbacks(IDefaultActions instance)
|
||||
{
|
||||
if (m_Wrapper.m_DefaultActionsCallbackInterfaces.Remove(instance))
|
||||
UnregisterCallbacks(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces all existing callback instances and previously registered input action callbacks associated with them with callbacks provided via <param cref="instance" />.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If <paramref name="instance" /> is <c>null</c>, calling this method will only unregister all existing callbacks but not register any new callbacks.
|
||||
/// </remarks>
|
||||
/// <seealso cref="DefaultActions.AddCallbacks(IDefaultActions)" />
|
||||
/// <seealso cref="DefaultActions.RemoveCallbacks(IDefaultActions)" />
|
||||
/// <seealso cref="DefaultActions.UnregisterCallbacks(IDefaultActions)" />
|
||||
public void SetCallbacks(IDefaultActions instance)
|
||||
{
|
||||
foreach (var item in m_Wrapper.m_DefaultActionsCallbackInterfaces)
|
||||
UnregisterCallbacks(item);
|
||||
m_Wrapper.m_DefaultActionsCallbackInterfaces.Clear();
|
||||
AddCallbacks(instance);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Provides a new <see cref="DefaultActions" /> instance referencing this action map.
|
||||
/// </summary>
|
||||
public DefaultActions @Default => new DefaultActions(this);
|
||||
|
||||
// Marketing
|
||||
private readonly InputActionMap m_Marketing;
|
||||
private List<IMarketingActions> m_MarketingActionsCallbackInterfaces = new List<IMarketingActions>();
|
||||
private readonly InputAction m_Marketing_CameraFOV;
|
||||
private readonly InputAction m_Marketing_CameraUpDown;
|
||||
private readonly InputAction m_Marketing_CameraRotationX;
|
||||
private readonly InputAction m_Marketing_CameraRotationY;
|
||||
/// <summary>
|
||||
/// Provides access to input actions defined in input action map "Marketing".
|
||||
/// </summary>
|
||||
public struct MarketingActions
|
||||
{
|
||||
private @InputConfig m_Wrapper;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a new instance of the input action map wrapper class.
|
||||
/// </summary>
|
||||
public MarketingActions(@InputConfig wrapper) { m_Wrapper = wrapper; }
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action "Marketing/CameraFOV".
|
||||
/// </summary>
|
||||
public InputAction @CameraFOV => m_Wrapper.m_Marketing_CameraFOV;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action "Marketing/CameraUpDown".
|
||||
/// </summary>
|
||||
public InputAction @CameraUpDown => m_Wrapper.m_Marketing_CameraUpDown;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action "Marketing/CameraRotationX".
|
||||
/// </summary>
|
||||
public InputAction @CameraRotationX => m_Wrapper.m_Marketing_CameraRotationX;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action "Marketing/CameraRotationY".
|
||||
/// </summary>
|
||||
public InputAction @CameraRotationY => m_Wrapper.m_Marketing_CameraRotationY;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action map instance.
|
||||
/// </summary>
|
||||
public InputActionMap Get() { return m_Wrapper.m_Marketing; }
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.Enable()" />
|
||||
public void Enable() { Get().Enable(); }
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.Disable()" />
|
||||
public void Disable() { Get().Disable(); }
|
||||
/// <inheritdoc cref="UnityEngine.InputSystem.InputActionMap.enabled" />
|
||||
public bool enabled => Get().enabled;
|
||||
/// <summary>
|
||||
/// Implicitly converts an <see ref="MarketingActions" /> to an <see ref="InputActionMap" /> instance.
|
||||
/// </summary>
|
||||
public static implicit operator InputActionMap(MarketingActions set) { return set.Get(); }
|
||||
/// <summary>
|
||||
/// Adds <see cref="InputAction.started"/>, <see cref="InputAction.performed"/> and <see cref="InputAction.canceled"/> callbacks provided via <param cref="instance" /> on all input actions contained in this map.
|
||||
/// </summary>
|
||||
/// <param name="instance">Callback instance.</param>
|
||||
/// <remarks>
|
||||
/// If <paramref name="instance" /> is <c>null</c> or <paramref name="instance"/> have already been added this method does nothing.
|
||||
/// </remarks>
|
||||
/// <seealso cref="MarketingActions" />
|
||||
public void AddCallbacks(IMarketingActions instance)
|
||||
{
|
||||
if (instance == null || m_Wrapper.m_MarketingActionsCallbackInterfaces.Contains(instance)) return;
|
||||
m_Wrapper.m_MarketingActionsCallbackInterfaces.Add(instance);
|
||||
@CameraFOV.started += instance.OnCameraFOV;
|
||||
@CameraFOV.performed += instance.OnCameraFOV;
|
||||
@CameraFOV.canceled += instance.OnCameraFOV;
|
||||
@CameraUpDown.started += instance.OnCameraUpDown;
|
||||
@CameraUpDown.performed += instance.OnCameraUpDown;
|
||||
@CameraUpDown.canceled += instance.OnCameraUpDown;
|
||||
@CameraRotationX.started += instance.OnCameraRotationX;
|
||||
@CameraRotationX.performed += instance.OnCameraRotationX;
|
||||
@CameraRotationX.canceled += instance.OnCameraRotationX;
|
||||
@CameraRotationY.started += instance.OnCameraRotationY;
|
||||
@CameraRotationY.performed += instance.OnCameraRotationY;
|
||||
@CameraRotationY.canceled += instance.OnCameraRotationY;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes <see cref="InputAction.started"/>, <see cref="InputAction.performed"/> and <see cref="InputAction.canceled"/> callbacks provided via <param cref="instance" /> on all input actions contained in this map.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Calling this method when <paramref name="instance" /> have not previously been registered has no side-effects.
|
||||
/// </remarks>
|
||||
/// <seealso cref="MarketingActions" />
|
||||
private void UnregisterCallbacks(IMarketingActions instance)
|
||||
{
|
||||
@CameraFOV.started -= instance.OnCameraFOV;
|
||||
@CameraFOV.performed -= instance.OnCameraFOV;
|
||||
@CameraFOV.canceled -= instance.OnCameraFOV;
|
||||
@CameraUpDown.started -= instance.OnCameraUpDown;
|
||||
@CameraUpDown.performed -= instance.OnCameraUpDown;
|
||||
@CameraUpDown.canceled -= instance.OnCameraUpDown;
|
||||
@CameraRotationX.started -= instance.OnCameraRotationX;
|
||||
@CameraRotationX.performed -= instance.OnCameraRotationX;
|
||||
@CameraRotationX.canceled -= instance.OnCameraRotationX;
|
||||
@CameraRotationY.started -= instance.OnCameraRotationY;
|
||||
@CameraRotationY.performed -= instance.OnCameraRotationY;
|
||||
@CameraRotationY.canceled -= instance.OnCameraRotationY;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unregisters <param cref="instance" /> and unregisters all input action callbacks via <see cref="MarketingActions.UnregisterCallbacks(IMarketingActions)" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="MarketingActions.UnregisterCallbacks(IMarketingActions)" />
|
||||
public void RemoveCallbacks(IMarketingActions instance)
|
||||
{
|
||||
if (m_Wrapper.m_MarketingActionsCallbackInterfaces.Remove(instance))
|
||||
UnregisterCallbacks(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces all existing callback instances and previously registered input action callbacks associated with them with callbacks provided via <param cref="instance" />.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If <paramref name="instance" /> is <c>null</c>, calling this method will only unregister all existing callbacks but not register any new callbacks.
|
||||
/// </remarks>
|
||||
/// <seealso cref="MarketingActions.AddCallbacks(IMarketingActions)" />
|
||||
/// <seealso cref="MarketingActions.RemoveCallbacks(IMarketingActions)" />
|
||||
/// <seealso cref="MarketingActions.UnregisterCallbacks(IMarketingActions)" />
|
||||
public void SetCallbacks(IMarketingActions instance)
|
||||
{
|
||||
foreach (var item in m_Wrapper.m_MarketingActionsCallbackInterfaces)
|
||||
UnregisterCallbacks(item);
|
||||
m_Wrapper.m_MarketingActionsCallbackInterfaces.Clear();
|
||||
AddCallbacks(instance);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Provides a new <see cref="MarketingActions" /> instance referencing this action map.
|
||||
/// </summary>
|
||||
public MarketingActions @Marketing => new MarketingActions(this);
|
||||
/// <summary>
|
||||
/// Interface to implement callback methods for all input action callbacks associated with input actions defined by "Default" which allows adding and removing callbacks.
|
||||
/// </summary>
|
||||
/// <seealso cref="DefaultActions.AddCallbacks(IDefaultActions)" />
|
||||
/// <seealso cref="DefaultActions.RemoveCallbacks(IDefaultActions)" />
|
||||
public interface IDefaultActions
|
||||
{
|
||||
/// <summary>
|
||||
/// Method invoked when associated input action "Camera Horizontal" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnCameraHorizontal(InputAction.CallbackContext context);
|
||||
/// <summary>
|
||||
/// Method invoked when associated input action "Camera Vertical" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnCameraVertical(InputAction.CallbackContext context);
|
||||
}
|
||||
/// <summary>
|
||||
/// Interface to implement callback methods for all input action callbacks associated with input actions defined by "Marketing" which allows adding and removing callbacks.
|
||||
/// </summary>
|
||||
/// <seealso cref="MarketingActions.AddCallbacks(IMarketingActions)" />
|
||||
/// <seealso cref="MarketingActions.RemoveCallbacks(IMarketingActions)" />
|
||||
public interface IMarketingActions
|
||||
{
|
||||
/// <summary>
|
||||
/// Method invoked when associated input action "CameraFOV" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnCameraFOV(InputAction.CallbackContext context);
|
||||
/// <summary>
|
||||
/// Method invoked when associated input action "CameraUpDown" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnCameraUpDown(InputAction.CallbackContext context);
|
||||
/// <summary>
|
||||
/// Method invoked when associated input action "CameraRotationX" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnCameraRotationX(InputAction.CallbackContext context);
|
||||
/// <summary>
|
||||
/// Method invoked when associated input action "CameraRotationY" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnCameraRotationY(InputAction.CallbackContext context);
|
||||
}
|
||||
}
|
||||
2
Assets/InputConfig.cs.meta
Normal file
2
Assets/InputConfig.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 24f8ebac435e83c4c9a5f76647590d28
|
||||
275
Assets/InputConfig.inputactions
Normal file
275
Assets/InputConfig.inputactions
Normal file
@@ -0,0 +1,275 @@
|
||||
{
|
||||
"version": 1,
|
||||
"name": "InputConfig",
|
||||
"maps": [
|
||||
{
|
||||
"name": "Default",
|
||||
"id": "0625d9c0-43b5-4745-824b-9fda8ba30fee",
|
||||
"actions": [
|
||||
{
|
||||
"name": "Camera Horizontal",
|
||||
"type": "Value",
|
||||
"id": "c07137df-45a6-4c7f-a7a9-4a0308e41992",
|
||||
"expectedControlType": "Axis",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "Camera Vertical",
|
||||
"type": "Value",
|
||||
"id": "65ba5ae5-0f08-4c90-85ef-ff497cb253b9",
|
||||
"expectedControlType": "Axis",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
{
|
||||
"name": "",
|
||||
"id": "9ec96503-2099-45d3-aaf2-cf1475edb473",
|
||||
"path": "<Gamepad>/leftStick/x",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Camera Horizontal",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "1D Axis",
|
||||
"id": "ed76a404-3e05-4d45-a021-05844bc10505",
|
||||
"path": "1DAxis",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Camera Horizontal",
|
||||
"isComposite": true,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "negative",
|
||||
"id": "d655a04f-766a-439d-901d-794696b1ec89",
|
||||
"path": "<Keyboard>/a",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Camera Horizontal",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "positive",
|
||||
"id": "b0d947fc-bec7-46a7-9704-afc08a1e2886",
|
||||
"path": "<Keyboard>/d",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Camera Horizontal",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "ede8a471-011b-444f-aea7-3079794926f1",
|
||||
"path": "<Gamepad>/leftStick/y",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Camera Vertical",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "1D Axis",
|
||||
"id": "e9f01183-aa1d-4ebf-9799-09aec02d3cf8",
|
||||
"path": "1DAxis",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Camera Vertical",
|
||||
"isComposite": true,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "negative",
|
||||
"id": "908edb1a-3d82-4454-9d8e-2020aafd0714",
|
||||
"path": "<Keyboard>/s",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Camera Vertical",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "positive",
|
||||
"id": "34639f79-f10f-4950-96dc-b2a5ab43c4a7",
|
||||
"path": "<Keyboard>/w",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Camera Vertical",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Marketing",
|
||||
"id": "56f2eb0a-da06-47a3-9123-f39cfe90e6a1",
|
||||
"actions": [
|
||||
{
|
||||
"name": "CameraFOV",
|
||||
"type": "Value",
|
||||
"id": "970c903e-bdb9-42ab-b5e5-0e5019ac0994",
|
||||
"expectedControlType": "Axis",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "CameraUpDown",
|
||||
"type": "Value",
|
||||
"id": "ad16855f-155a-4c1c-9557-171868403461",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "CameraRotationX",
|
||||
"type": "Value",
|
||||
"id": "f47fc852-b65d-4ae3-8ee4-c4e948103760",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "CameraRotationY",
|
||||
"type": "Value",
|
||||
"id": "54a4cdd3-92f4-4562-bc26-932f1ecf3961",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
{
|
||||
"name": "1D Axis",
|
||||
"id": "5b23e3c8-fa10-4d03-81ba-247c869d1e57",
|
||||
"path": "1DAxis",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "CameraFOV",
|
||||
"isComposite": true,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "negative",
|
||||
"id": "ebd13f12-54ac-4f07-b24b-8794856068a5",
|
||||
"path": "<Keyboard>/o",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "CameraFOV",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "positive",
|
||||
"id": "6e9ad397-b3d9-4b84-ab9c-fc1621b99e13",
|
||||
"path": "<Keyboard>/p",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "CameraFOV",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "c0c2a08a-f7cc-4b85-bfc0-d645d7b3f48f",
|
||||
"path": "<Gamepad>/dpad/x",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "CameraFOV",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "8d66cc2f-effa-47c4-8d9c-f1f89c9fbebc",
|
||||
"path": "<Gamepad>/dpad/y",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "CameraUpDown",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "1D Axis",
|
||||
"id": "77e92290-0b17-41f7-a044-9109ddfb1149",
|
||||
"path": "1DAxis",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "CameraUpDown",
|
||||
"isComposite": true,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "negative",
|
||||
"id": "1797a6a8-20e6-420a-9623-f49123d9c18a",
|
||||
"path": "<Keyboard>/k",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "CameraUpDown",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "positive",
|
||||
"id": "77a25d8f-be60-4403-84a5-b32f4199555b",
|
||||
"path": "<Keyboard>/l",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "CameraUpDown",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "1a68b1f2-634e-47f5-b88c-29be850e1a75",
|
||||
"path": "<Gamepad>/rightStick/x",
|
||||
"interactions": "",
|
||||
"processors": "Invert",
|
||||
"groups": "",
|
||||
"action": "CameraRotationX",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "222a9167-cf4e-473e-bcd8-173c4084fa81",
|
||||
"path": "<Gamepad>/rightStick/y",
|
||||
"interactions": "",
|
||||
"processors": "Invert",
|
||||
"groups": "",
|
||||
"action": "CameraRotationY",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"controlSchemes": []
|
||||
}
|
||||
7
Assets/InputConfig.inputactions.meta
Normal file
7
Assets/InputConfig.inputactions.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c7b9246b90bb9c4ab7519d0cb909720
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,3 +1,4 @@
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class FirstPersonController : MonoBehaviour
|
||||
@@ -45,7 +46,8 @@ public class FirstPersonController : MonoBehaviour
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (controller == null) return;
|
||||
if( controller == null )
|
||||
return;
|
||||
|
||||
isGrounded = controller.isGrounded;
|
||||
|
||||
|
||||
8
Assets/Scripts/Game.meta
Normal file
8
Assets/Scripts/Game.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95d67a3c950d0c04bbf9b00db7424ff8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Assets/Scripts/Game/Defines.cs
Normal file
25
Assets/Scripts/Game/Defines.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Defines
|
||||
{
|
||||
public class Input
|
||||
{
|
||||
public const int kLeftMouseButton = 0;
|
||||
public const int kRightMouseButton = 1;
|
||||
public const int kMiddleMouseButton = 2;
|
||||
|
||||
public const float kShortClickDelay = 0.25f;
|
||||
public const float kShortClickCancelMinMouseMovement = 10.0f;
|
||||
|
||||
public const float kHeldClickDelay = 0.3f;
|
||||
|
||||
public const KeyCode rotateLeftKey = KeyCode.R;
|
||||
public const KeyCode rotateRightKey = KeyCode.T;
|
||||
public const KeyCode kCancelKeyCode = KeyCode.Escape;
|
||||
|
||||
public const CursorLockMode kDefaultCursorLockMode = CursorLockMode.Confined;
|
||||
|
||||
public const float kMouseRotationDistance = 100.0f;
|
||||
public const float kDoubleClickThreshold = 0.5f;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Game/Defines.cs.meta
Normal file
2
Assets/Scripts/Game/Defines.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87ada8c9eefa71f47aefa0442b6e990f
|
||||
8
Assets/Scripts/Game/Input.meta
Normal file
8
Assets/Scripts/Game/Input.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d14cfa81116a2f342bb961c77495567a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
474
Assets/Scripts/Game/Input/InputData.cs
Normal file
474
Assets/Scripts/Game/Input/InputData.cs
Normal file
@@ -0,0 +1,474 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public static class InputData
|
||||
{
|
||||
public const float kDoubleClickThreshold = 0.5f;
|
||||
|
||||
public static Vector2 mousePosition;
|
||||
public static Vector2 mouseDelta;
|
||||
public static float smoothScrollDelta;
|
||||
public static float scrollDelta;
|
||||
|
||||
public static bool mouseOverUI
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public static MouseButton leftMouseButton;
|
||||
public static MouseButton middleMouseButton;
|
||||
public static MouseButton rightMouseButton;
|
||||
|
||||
public static Button up;
|
||||
public static Button down;
|
||||
public static Button debugButton;
|
||||
public static Button agentDebugButton;
|
||||
|
||||
public static Button rotateLeft;
|
||||
public static Button rotateRight;
|
||||
|
||||
public static Button cancel;
|
||||
|
||||
public static Button floorUp;
|
||||
public static Button floorDown;
|
||||
|
||||
public static Button cameraLeft;
|
||||
public static Button cameraRight;
|
||||
public static Button cameraUp;
|
||||
public static Button cameraDown;
|
||||
public static Button cameraRotateLeft;
|
||||
public static Button cameraRotateRight;
|
||||
public static Button cameraSpeedBoost;
|
||||
|
||||
public static Button pauseTime;
|
||||
|
||||
public static Button pauseGame;
|
||||
|
||||
public static Axis cameraHorizontal;
|
||||
public static Axis cameraVertical;
|
||||
|
||||
#if MARKETING_BUILD
|
||||
|
||||
public static Axis fovAxis;
|
||||
|
||||
public static Axis cameraUpDownAxis;
|
||||
public static Axis marketingCameraX;
|
||||
public static Axis marketingCameraY;
|
||||
|
||||
#endif
|
||||
|
||||
private static List<Button> allButtons = new List<Button>();
|
||||
private static List<Axis> allAxis = new List<Axis>();
|
||||
|
||||
private static float storedScrollDelta;
|
||||
|
||||
private static InputConfig inputConfig = new InputConfig();
|
||||
|
||||
static InputData()
|
||||
{
|
||||
leftMouseButton = AddButton( new MouseButton( Defines.Input.kLeftMouseButton ) );
|
||||
middleMouseButton = AddButton( new MouseButton( Defines.Input.kMiddleMouseButton ) );
|
||||
rightMouseButton = AddButton( new MouseButton( Defines.Input.kRightMouseButton ) );
|
||||
|
||||
up = AddButton( new KeyboardButton( KeyCode.UpArrow ) );
|
||||
down = AddButton( new KeyboardButton( KeyCode.DownArrow ) );
|
||||
|
||||
rotateLeft = AddButton( new KeyboardButton( Defines.Input.rotateLeftKey ) );
|
||||
rotateRight = AddButton( new KeyboardButton( Defines.Input.rotateRightKey ) );
|
||||
|
||||
cancel = AddButton( new KeyboardButton( Defines.Input.kCancelKeyCode ) );
|
||||
pauseGame = AddButton( new KeyboardButton( KeyCode.Escape ) );
|
||||
|
||||
debugButton = AddButton( new KeyboardButton( KeyCode.Space ) );
|
||||
agentDebugButton = AddButton( new KeyboardButton( KeyCode.Z ) );
|
||||
|
||||
floorUp = AddButton( new MultiButton(
|
||||
new Button[]
|
||||
{
|
||||
new KeyboardButton( KeyCode.Alpha2 ),
|
||||
new KeyboardButton( KeyCode.G )
|
||||
} ) );
|
||||
floorDown = AddButton( new MultiButton(
|
||||
new Button[]
|
||||
{
|
||||
new KeyboardButton( KeyCode.Alpha1 ),
|
||||
new KeyboardButton( KeyCode.F )
|
||||
} ) );
|
||||
|
||||
cameraLeft = AddButton( new MultiButton(
|
||||
new Button[]
|
||||
{
|
||||
new KeyboardButton( KeyCode.A ),
|
||||
new KeyboardButton( KeyCode.LeftArrow )
|
||||
} ) );
|
||||
cameraRight = AddButton( new MultiButton(
|
||||
new Button[]
|
||||
{
|
||||
new KeyboardButton( KeyCode.D ),
|
||||
new KeyboardButton( KeyCode.RightArrow )
|
||||
} ) );
|
||||
cameraUp = AddButton( new MultiButton(
|
||||
new Button[]
|
||||
{
|
||||
new KeyboardButton( KeyCode.W ),
|
||||
new KeyboardButton( KeyCode.UpArrow )
|
||||
} ) );
|
||||
cameraDown = AddButton( new MultiButton(
|
||||
new Button[]
|
||||
{
|
||||
new KeyboardButton( KeyCode.S ),
|
||||
new KeyboardButton( KeyCode.DownArrow )
|
||||
} ) );
|
||||
cameraRotateLeft = AddButton( new KeyboardButton( KeyCode.Q ) );
|
||||
cameraRotateRight = AddButton( new KeyboardButton( KeyCode.E ) );
|
||||
cameraSpeedBoost = AddButton( new KeyboardButton( KeyCode.LeftShift ) );
|
||||
|
||||
pauseTime = AddButton( new KeyboardButton( KeyCode.Space ) );
|
||||
|
||||
inputConfig.Default.Enable();
|
||||
|
||||
cameraHorizontal = AddAxis( new MultiAxis(
|
||||
new Axis[]
|
||||
{
|
||||
new InputActionAxis( inputConfig.Default.CameraHorizontal )
|
||||
} ) );
|
||||
cameraVertical = AddAxis( new MultiAxis(
|
||||
new Axis[]
|
||||
{
|
||||
new InputActionAxis( inputConfig.Default.CameraVertical )
|
||||
} ) );
|
||||
|
||||
|
||||
#if MARKETING_BUILD
|
||||
|
||||
inputConfig.Marketing.Enable();
|
||||
fovAxis = AddAxis( new InputActionAxis( inputConfig.Marketing.CameraFOV ) );
|
||||
|
||||
cameraUpDownAxis = AddAxis( new InputActionAxis( inputConfig.Marketing.CameraUpDown ) );
|
||||
|
||||
marketingCameraX = AddAxis( new InputActionAxis( inputConfig.Marketing.CameraRotationX ) );
|
||||
marketingCameraY = AddAxis( new InputActionAxis( inputConfig.Marketing.CameraRotationY ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
public static T AddButton<T>( T value ) where T : Button
|
||||
{
|
||||
allButtons.Add( value );
|
||||
return value;
|
||||
}
|
||||
|
||||
public static T AddAxis<T>( T value ) where T : Axis
|
||||
{
|
||||
allAxis.Add( value );
|
||||
return value;
|
||||
}
|
||||
|
||||
public class MouseButton : Button
|
||||
{
|
||||
public Vector2 downPosition;
|
||||
public int mouseButton;
|
||||
|
||||
public MouseButton( int button )
|
||||
{
|
||||
mouseButton = button;
|
||||
}
|
||||
|
||||
public override bool GetButton()
|
||||
{
|
||||
return Input.GetMouseButton( mouseButton );
|
||||
}
|
||||
|
||||
protected override bool HeldCancelCheck()
|
||||
{
|
||||
return ( mousePosition - downPosition ).magnitude <= Defines.Input.kShortClickCancelMinMouseMovement;
|
||||
}
|
||||
|
||||
public override void Update( float unscaledTime )
|
||||
{
|
||||
base.Update( unscaledTime );
|
||||
if( pressed )
|
||||
{
|
||||
downPosition = mousePosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class KeyboardButton : Button
|
||||
{
|
||||
private KeyCode key;
|
||||
|
||||
public KeyboardButton( KeyCode keycode )
|
||||
{
|
||||
key = keycode;
|
||||
}
|
||||
|
||||
public override bool GetButton()
|
||||
{
|
||||
return Input.GetKey( key );
|
||||
}
|
||||
}
|
||||
|
||||
public class MultiButton : Button
|
||||
{
|
||||
private Button[] buttons;
|
||||
|
||||
public MultiButton( Button[] value )
|
||||
{
|
||||
buttons = value;
|
||||
}
|
||||
|
||||
public override bool GetButton()
|
||||
{
|
||||
bool down = false;
|
||||
for( int i = buttons.Length - 1; i >= 0; --i )
|
||||
{
|
||||
down |= buttons[i].GetButton();
|
||||
}
|
||||
return down;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class Button
|
||||
{
|
||||
/// <summary>
|
||||
/// true when the mouse button is down.
|
||||
/// </summary>
|
||||
public bool down;
|
||||
/// <summary>
|
||||
/// true for the frame that the mouse button pressed (On Click).
|
||||
/// </summary>
|
||||
public bool pressed;
|
||||
/// <summary>
|
||||
/// true on the frame that the mouse button has been down
|
||||
/// for X number of frames without being moved.
|
||||
/// </summary>
|
||||
public bool held;
|
||||
/// <summary>
|
||||
/// true on the frame the mouse button is released.
|
||||
/// </summary>
|
||||
public bool released;
|
||||
/// <summary>
|
||||
/// true if the mouse is clicked quickly and not moved much.
|
||||
/// example: right clicking to cancel placement of item.
|
||||
/// </summary>
|
||||
public bool shortClick;
|
||||
|
||||
/// <summary>
|
||||
/// The time that the button was presesd.
|
||||
/// </summary>
|
||||
public float downTime;
|
||||
|
||||
/// <summary>
|
||||
/// True when the user has double clicked this button.
|
||||
/// </summary>
|
||||
public bool doubleClick;
|
||||
|
||||
/// <summary>
|
||||
/// How long this button has been down for. Only valid when
|
||||
/// down == true
|
||||
/// </summary>
|
||||
public float downLength;
|
||||
|
||||
private bool isHeld;
|
||||
private float lastClickTime;
|
||||
private Vector3 lastClickPosition;
|
||||
|
||||
public abstract bool GetButton();
|
||||
/// <summary>
|
||||
/// Overload this funtion in order to have
|
||||
/// the mouse be able to cancel the held functionality
|
||||
/// if the user moves the mouse.
|
||||
/// </summary>
|
||||
/// <returns>If the held or shortclick should be cancelled</returns>
|
||||
protected virtual bool HeldCancelCheck()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Update( float unscaledTime )
|
||||
{
|
||||
bool value = GetButton();
|
||||
|
||||
pressed = value && down == false;
|
||||
released = value == false && down == true;
|
||||
shortClick = false;
|
||||
down = value;
|
||||
|
||||
bool isHeldValue = pressed == false && down && downTime + Defines.Input.kHeldClickDelay < unscaledTime && HeldCancelCheck();
|
||||
held = isHeld == false && isHeldValue == true; // Only show this as true for a single frame.
|
||||
isHeld = isHeldValue;
|
||||
|
||||
if( pressed )
|
||||
{
|
||||
downTime = unscaledTime;
|
||||
downLength = 0.0f;
|
||||
doubleClick = lastClickTime + kDoubleClickThreshold >= unscaledTime && Vector2.Distance( mousePosition, lastClickPosition ) < 5.0f;
|
||||
}
|
||||
|
||||
if( released )
|
||||
{
|
||||
if( unscaledTime - downTime <= Defines.Input.kShortClickDelay
|
||||
&& HeldCancelCheck() )
|
||||
{
|
||||
shortClick = true;
|
||||
}
|
||||
lastClickTime = unscaledTime;
|
||||
doubleClick = false;
|
||||
}
|
||||
|
||||
if( down )
|
||||
{
|
||||
downLength = unscaledTime - downTime;
|
||||
lastClickPosition = mousePosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class Axis
|
||||
{
|
||||
public float value;
|
||||
|
||||
public abstract float GetAxisValue();
|
||||
|
||||
public virtual void Update()
|
||||
{
|
||||
value = GetAxisValue();
|
||||
}
|
||||
}
|
||||
|
||||
public class InputAxis : Axis
|
||||
{
|
||||
public string axisName;
|
||||
|
||||
public InputAxis( string name )
|
||||
{
|
||||
axisName = name;
|
||||
}
|
||||
|
||||
public override float GetAxisValue()
|
||||
{
|
||||
return Input.GetAxis( axisName );
|
||||
}
|
||||
}
|
||||
|
||||
public class TriggerNormaliser : Axis
|
||||
{
|
||||
private Axis trigger;
|
||||
bool invert = false;
|
||||
|
||||
public TriggerNormaliser( Axis value, bool doInvert )
|
||||
{
|
||||
trigger = value;
|
||||
invert = doInvert;
|
||||
}
|
||||
|
||||
public override float GetAxisValue()
|
||||
{
|
||||
float value = trigger.GetAxisValue();
|
||||
if( invert == false )
|
||||
{
|
||||
value += 1.0f;
|
||||
value /= 2.0f;
|
||||
}
|
||||
value *= invert ? -1.0f : 1.0f;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public class InvertAxis : Axis
|
||||
{
|
||||
private Axis targetAxis;
|
||||
|
||||
public InvertAxis( Axis target )
|
||||
{
|
||||
targetAxis = target;
|
||||
}
|
||||
|
||||
public override float GetAxisValue()
|
||||
{
|
||||
return -1 * targetAxis.GetAxisValue();
|
||||
}
|
||||
}
|
||||
|
||||
public class ButtonAxis : Axis
|
||||
{
|
||||
private Button positiveButton;
|
||||
private Button negativeButton;
|
||||
|
||||
public ButtonAxis( Button negativeButton, Button positiveButton )
|
||||
{
|
||||
this.positiveButton = positiveButton;
|
||||
this.negativeButton = negativeButton;
|
||||
}
|
||||
|
||||
public override float GetAxisValue()
|
||||
{
|
||||
return ( positiveButton.down ? 1.0f : 0.0f ) + ( negativeButton.down ? -1.0f : 0.0f );
|
||||
}
|
||||
}
|
||||
|
||||
public class InputActionAxis : Axis
|
||||
{
|
||||
private InputAction action;
|
||||
|
||||
public InputActionAxis( InputAction inputAction )
|
||||
{
|
||||
action = inputAction;
|
||||
}
|
||||
|
||||
public override float GetAxisValue()
|
||||
{
|
||||
return action.ReadValue<float>();
|
||||
}
|
||||
}
|
||||
|
||||
public class MultiAxis : Axis
|
||||
{
|
||||
protected Axis[] axis;
|
||||
|
||||
public MultiAxis( Axis[] axis )
|
||||
{
|
||||
this.axis = axis;
|
||||
}
|
||||
|
||||
public override float GetAxisValue()
|
||||
{
|
||||
float value = 0.0f;
|
||||
|
||||
for( int i = 0; i < axis.Length; i++ )
|
||||
{
|
||||
value += axis[i].GetAxisValue();
|
||||
}
|
||||
|
||||
value = Mathf.Clamp( value, -1.0f, 1.0f );
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Update( float unscaledTime )
|
||||
{
|
||||
mouseDelta = mousePosition - (Vector2)Input.mousePosition;
|
||||
mousePosition = Input.mousePosition;
|
||||
//mouseOverUI = UIUtils.MouseIsOverUI();
|
||||
foreach( Button i in allButtons )
|
||||
{
|
||||
i.Update( unscaledTime );
|
||||
}
|
||||
|
||||
foreach( Axis i in allAxis )
|
||||
{
|
||||
i.Update();
|
||||
}
|
||||
|
||||
#if UNITY_STANDALONE_WIN
|
||||
scrollDelta = Input.mouseScrollDelta.y;
|
||||
#else
|
||||
scrollDelta = ( Input.GetKey( KeyCode.LeftShift ) || Input.GetKey( KeyCode.RightShift ) ) ? Input.mouseScrollDelta.x : Input.mouseScrollDelta.y;
|
||||
#endif
|
||||
storedScrollDelta += scrollDelta;
|
||||
float smoothAmount = Mathf.Lerp( 0.0f, storedScrollDelta, Time.unscaledDeltaTime * 5.0f );
|
||||
storedScrollDelta -= smoothAmount;
|
||||
smoothScrollDelta = smoothAmount;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Game/Input/InputData.cs.meta
Normal file
2
Assets/Scripts/Game/Input/InputData.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b47ddc9765face745a9c52aaf22038bc
|
||||
@@ -3,6 +3,7 @@
|
||||
"com.atteneder.gltfast": "https://github.com/atteneder/glTFast.git",
|
||||
"com.unity.collab-proxy": "2.11.3",
|
||||
"com.unity.feature.development": "1.0.2",
|
||||
"com.unity.inputsystem": "1.18.0",
|
||||
"com.unity.multiplayer.center": "1.0.1",
|
||||
"com.unity.probuilder": "6.0.8",
|
||||
"com.unity.render-pipelines.universal": "17.3.0",
|
||||
|
||||
@@ -87,6 +87,15 @@
|
||||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.inputsystem": {
|
||||
"version": "1.18.0",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.modules.uielements": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.mathematics": {
|
||||
"version": "1.3.3",
|
||||
"depth": 1,
|
||||
|
||||
@@ -786,7 +786,7 @@ PlayerSettings:
|
||||
qnxGraphicConfPath:
|
||||
apiCompatibilityLevel: 6
|
||||
captureStartupLogs: {}
|
||||
activeInputHandler: 0
|
||||
activeInputHandler: 2
|
||||
windowsGamepadBackendHint: 0
|
||||
cloudProjectId: 217a922e-0f32-4f7e-a178-6ba09a1ca576
|
||||
framebufferDepthMemorylessMode: 0
|
||||
|
||||
Reference in New Issue
Block a user