IndieGame/client/Packages/com.unity.inputsystem@1.7.0/Samples~/DocsExamples/Actions/SimpleActions.cs
DOBEST\zhaoyingjie f242607587 初始化工程
2024-10-11 10:12:15 +08:00

185 lines
6.4 KiB
C#

//------------------------------------------------------------------------------
// <auto-generated>
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
// version 1.4.3
// from Assets/Samples/DocsSamples/SimpleActions.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;
public partial class @SimpleActions: IInputActionCollection2, IDisposable
{
public InputActionAsset asset { get; }
public @SimpleActions()
{
asset = InputActionAsset.FromJson(@"{
""name"": ""SimpleActions"",
""maps"": [
{
""name"": ""gameplay"",
""id"": ""d55be63c-61eb-47ef-92dd-eef1248d601e"",
""actions"": [
{
""name"": ""move"",
""type"": ""Value"",
""id"": ""8387a17d-aedd-4411-9931-6a855a8299fb"",
""expectedControlType"": ""Vector2"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": true
},
{
""name"": ""jump"",
""type"": ""Button"",
""id"": ""7fc1eb3c-b4d1-4aba-9a58-f36cac532d06"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
{
""name"": """",
""id"": ""2c541328-ed00-4524-817c-97599bac7de5"",
""path"": ""<Gamepad>{Player1}/leftStick"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""move"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""c48db537-b211-412a-a86a-d31614bebb5d"",
""path"": ""<Gamepad>{Player1}/buttonSouth"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""jump"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
],
""controlSchemes"": []
}");
// gameplay
m_gameplay = asset.FindActionMap("gameplay", throwIfNotFound: true);
m_gameplay_move = m_gameplay.FindAction("move", throwIfNotFound: true);
m_gameplay_jump = m_gameplay.FindAction("jump", throwIfNotFound: true);
}
public void Dispose()
{
UnityEngine.Object.Destroy(asset);
}
public InputBinding? bindingMask
{
get => asset.bindingMask;
set => asset.bindingMask = value;
}
public ReadOnlyArray<InputDevice>? devices
{
get => asset.devices;
set => asset.devices = value;
}
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
public bool Contains(InputAction action)
{
return asset.Contains(action);
}
public IEnumerator<InputAction> GetEnumerator()
{
return asset.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Enable()
{
asset.Enable();
}
public void Disable()
{
asset.Disable();
}
public IEnumerable<InputBinding> 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);
}
// gameplay
private readonly InputActionMap m_gameplay;
private IGameplayActions m_GameplayActionsCallbackInterface;
private readonly InputAction m_gameplay_move;
private readonly InputAction m_gameplay_jump;
public struct GameplayActions
{
private @SimpleActions m_Wrapper;
public GameplayActions(@SimpleActions wrapper) { m_Wrapper = wrapper; }
public InputAction @move => m_Wrapper.m_gameplay_move;
public InputAction @jump => m_Wrapper.m_gameplay_jump;
public InputActionMap Get() { return m_Wrapper.m_gameplay; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(GameplayActions set) { return set.Get(); }
public void SetCallbacks(IGameplayActions instance)
{
if (m_Wrapper.m_GameplayActionsCallbackInterface != null)
{
@move.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
@move.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
@move.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnMove;
@jump.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@jump.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
@jump.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnJump;
}
m_Wrapper.m_GameplayActionsCallbackInterface = instance;
if (instance != null)
{
@move.started += instance.OnMove;
@move.performed += instance.OnMove;
@move.canceled += instance.OnMove;
@jump.started += instance.OnJump;
@jump.performed += instance.OnJump;
@jump.canceled += instance.OnJump;
}
}
}
public GameplayActions @gameplay => new GameplayActions(this);
public interface IGameplayActions
{
void OnMove(InputAction.CallbackContext context);
void OnJump(InputAction.CallbackContext context);
}
}