
1.添加基本操作:移动、跳跃、交互和攻击的按键监听,编写好了父类,使用时只需要继承PlayerControl,然后重写里面的函数即可,注释和摘要齐全,如无必要请勿修改
我是每天上班提醒小助手,今天你上班了吗?😺
425 lines
16 KiB
C#
425 lines
16 KiB
C#
//------------------------------------------------------------------------------
|
|
// <auto-generated>
|
|
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
|
|
// version 1.3.0
|
|
// from Assets/InputAssets/PlayerC.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 @PlayerC : IInputActionCollection2, IDisposable
|
|
{
|
|
public InputActionAsset asset { get; }
|
|
public @PlayerC()
|
|
{
|
|
asset = InputActionAsset.FromJson(@"{
|
|
""name"": ""PlayerC"",
|
|
""maps"": [
|
|
{
|
|
""name"": ""Normal"",
|
|
""id"": ""a9509238-4ac2-4968-9104-7e40d5ee5be8"",
|
|
""actions"": [
|
|
{
|
|
""name"": ""Move"",
|
|
""type"": ""Value"",
|
|
""id"": ""4850f4e1-f2c9-4d5c-bd75-a8673acfb61a"",
|
|
""expectedControlType"": ""Axis"",
|
|
""processors"": """",
|
|
""interactions"": """",
|
|
""initialStateCheck"": true
|
|
},
|
|
{
|
|
""name"": ""Atk"",
|
|
""type"": ""Button"",
|
|
""id"": ""514296f3-ecfc-4870-85d4-dd364fe8773e"",
|
|
""expectedControlType"": ""Button"",
|
|
""processors"": """",
|
|
""interactions"": """",
|
|
""initialStateCheck"": false
|
|
},
|
|
{
|
|
""name"": ""Jump"",
|
|
""type"": ""Button"",
|
|
""id"": ""abed25a0-995f-4034-84f5-d751e6bc0a7f"",
|
|
""expectedControlType"": ""Button"",
|
|
""processors"": """",
|
|
""interactions"": """",
|
|
""initialStateCheck"": false
|
|
},
|
|
{
|
|
""name"": ""Interact"",
|
|
""type"": ""Button"",
|
|
""id"": ""b014aa44-5a26-4e36-b7b0-2bf89fc8617c"",
|
|
""expectedControlType"": ""Button"",
|
|
""processors"": """",
|
|
""interactions"": """",
|
|
""initialStateCheck"": false
|
|
}
|
|
],
|
|
""bindings"": [
|
|
{
|
|
""name"": ""Keyboard"",
|
|
""id"": ""dfa90ca2-5172-40a9-a51c-0302d90846b4"",
|
|
""path"": ""1DAxis"",
|
|
""interactions"": """",
|
|
""processors"": """",
|
|
""groups"": """",
|
|
""action"": ""Move"",
|
|
""isComposite"": true,
|
|
""isPartOfComposite"": false
|
|
},
|
|
{
|
|
""name"": ""negative"",
|
|
""id"": ""034d425f-6336-4c6d-a571-d5bc9a090686"",
|
|
""path"": ""<Keyboard>/a"",
|
|
""interactions"": """",
|
|
""processors"": """",
|
|
""groups"": ""Normal"",
|
|
""action"": ""Move"",
|
|
""isComposite"": false,
|
|
""isPartOfComposite"": true
|
|
},
|
|
{
|
|
""name"": ""positive"",
|
|
""id"": ""d58eeeaf-86a4-4adc-acb8-c647c77cd7b4"",
|
|
""path"": ""<Keyboard>/d"",
|
|
""interactions"": """",
|
|
""processors"": """",
|
|
""groups"": ""Normal"",
|
|
""action"": ""Move"",
|
|
""isComposite"": false,
|
|
""isPartOfComposite"": true
|
|
},
|
|
{
|
|
""name"": ""GamePad"",
|
|
""id"": ""a4b44fd8-a2cb-4a05-ab0d-ac14de8d17b6"",
|
|
""path"": ""1DAxis"",
|
|
""interactions"": """",
|
|
""processors"": """",
|
|
""groups"": """",
|
|
""action"": ""Move"",
|
|
""isComposite"": true,
|
|
""isPartOfComposite"": false
|
|
},
|
|
{
|
|
""name"": ""negative"",
|
|
""id"": ""ca1377ed-502a-4c18-b5da-542b0ab2f78a"",
|
|
""path"": ""<Gamepad>/leftStick/left"",
|
|
""interactions"": """",
|
|
""processors"": """",
|
|
""groups"": ""Normal"",
|
|
""action"": ""Move"",
|
|
""isComposite"": false,
|
|
""isPartOfComposite"": true
|
|
},
|
|
{
|
|
""name"": ""positive"",
|
|
""id"": ""be7d0a09-9192-417e-b737-ea3e160f4156"",
|
|
""path"": ""<Gamepad>/leftStick/right"",
|
|
""interactions"": """",
|
|
""processors"": """",
|
|
""groups"": ""Normal"",
|
|
""action"": ""Move"",
|
|
""isComposite"": false,
|
|
""isPartOfComposite"": true
|
|
},
|
|
{
|
|
""name"": """",
|
|
""id"": ""74439205-ca18-4731-809e-9db029435012"",
|
|
""path"": ""<Keyboard>/j"",
|
|
""interactions"": """",
|
|
""processors"": """",
|
|
""groups"": """",
|
|
""action"": ""Atk"",
|
|
""isComposite"": false,
|
|
""isPartOfComposite"": false
|
|
},
|
|
{
|
|
""name"": """",
|
|
""id"": ""41256d78-e271-4ffe-a025-708f7f7dd055"",
|
|
""path"": ""<Gamepad>/buttonWest"",
|
|
""interactions"": """",
|
|
""processors"": """",
|
|
""groups"": """",
|
|
""action"": ""Atk"",
|
|
""isComposite"": false,
|
|
""isPartOfComposite"": false
|
|
},
|
|
{
|
|
""name"": """",
|
|
""id"": ""d26afab9-340e-4c38-905f-576f82ce664c"",
|
|
""path"": ""<Gamepad>/buttonSouth"",
|
|
""interactions"": """",
|
|
""processors"": """",
|
|
""groups"": """",
|
|
""action"": ""Jump"",
|
|
""isComposite"": false,
|
|
""isPartOfComposite"": false
|
|
},
|
|
{
|
|
""name"": """",
|
|
""id"": ""310e0ce7-9635-4c78-bf18-8b46b039dbb4"",
|
|
""path"": ""<Keyboard>/k"",
|
|
""interactions"": """",
|
|
""processors"": """",
|
|
""groups"": """",
|
|
""action"": ""Jump"",
|
|
""isComposite"": false,
|
|
""isPartOfComposite"": false
|
|
},
|
|
{
|
|
""name"": """",
|
|
""id"": ""56e4c8f3-5f31-4e4c-b216-914499d0d7a8"",
|
|
""path"": ""<Keyboard>/f"",
|
|
""interactions"": """",
|
|
""processors"": """",
|
|
""groups"": """",
|
|
""action"": ""Interact"",
|
|
""isComposite"": false,
|
|
""isPartOfComposite"": false
|
|
},
|
|
{
|
|
""name"": """",
|
|
""id"": ""d38f2194-30e2-45a5-a803-89534727cf65"",
|
|
""path"": ""<Gamepad>/buttonWest"",
|
|
""interactions"": """",
|
|
""processors"": """",
|
|
""groups"": """",
|
|
""action"": ""Interact"",
|
|
""isComposite"": false,
|
|
""isPartOfComposite"": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
""name"": ""Null"",
|
|
""id"": ""d35487bf-8b39-4ef8-932a-e057537f5cff"",
|
|
""actions"": [
|
|
{
|
|
""name"": ""New action"",
|
|
""type"": ""Button"",
|
|
""id"": ""8227df78-160c-4425-939a-fb42da1254ef"",
|
|
""expectedControlType"": ""Button"",
|
|
""processors"": """",
|
|
""interactions"": """",
|
|
""initialStateCheck"": false
|
|
}
|
|
],
|
|
""bindings"": [
|
|
{
|
|
""name"": """",
|
|
""id"": ""522de362-9c2e-4df0-8a98-33364cf3737b"",
|
|
""path"": """",
|
|
""interactions"": """",
|
|
""processors"": """",
|
|
""groups"": ""Normal"",
|
|
""action"": ""New action"",
|
|
""isComposite"": false,
|
|
""isPartOfComposite"": false
|
|
}
|
|
]
|
|
}
|
|
],
|
|
""controlSchemes"": [
|
|
{
|
|
""name"": ""Normal"",
|
|
""bindingGroup"": ""Normal"",
|
|
""devices"": [
|
|
{
|
|
""devicePath"": ""<Gamepad>"",
|
|
""isOptional"": true,
|
|
""isOR"": false
|
|
},
|
|
{
|
|
""devicePath"": ""<Keyboard>"",
|
|
""isOptional"": true,
|
|
""isOR"": false
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}");
|
|
// Normal
|
|
m_Normal = asset.FindActionMap("Normal", throwIfNotFound: true);
|
|
m_Normal_Move = m_Normal.FindAction("Move", throwIfNotFound: true);
|
|
m_Normal_Atk = m_Normal.FindAction("Atk", throwIfNotFound: true);
|
|
m_Normal_Jump = m_Normal.FindAction("Jump", throwIfNotFound: true);
|
|
m_Normal_Interact = m_Normal.FindAction("Interact", throwIfNotFound: true);
|
|
// Null
|
|
m_Null = asset.FindActionMap("Null", throwIfNotFound: true);
|
|
m_Null_Newaction = m_Null.FindAction("New action", 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);
|
|
}
|
|
|
|
// Normal
|
|
private readonly InputActionMap m_Normal;
|
|
private INormalActions m_NormalActionsCallbackInterface;
|
|
private readonly InputAction m_Normal_Move;
|
|
private readonly InputAction m_Normal_Atk;
|
|
private readonly InputAction m_Normal_Jump;
|
|
private readonly InputAction m_Normal_Interact;
|
|
public struct NormalActions
|
|
{
|
|
private @PlayerC m_Wrapper;
|
|
public NormalActions(@PlayerC wrapper) { m_Wrapper = wrapper; }
|
|
public InputAction @Move => m_Wrapper.m_Normal_Move;
|
|
public InputAction @Atk => m_Wrapper.m_Normal_Atk;
|
|
public InputAction @Jump => m_Wrapper.m_Normal_Jump;
|
|
public InputAction @Interact => m_Wrapper.m_Normal_Interact;
|
|
public InputActionMap Get() { return m_Wrapper.m_Normal; }
|
|
public void Enable() { Get().Enable(); }
|
|
public void Disable() { Get().Disable(); }
|
|
public bool enabled => Get().enabled;
|
|
public static implicit operator InputActionMap(NormalActions set) { return set.Get(); }
|
|
public void SetCallbacks(INormalActions instance)
|
|
{
|
|
if (m_Wrapper.m_NormalActionsCallbackInterface != null)
|
|
{
|
|
@Move.started -= m_Wrapper.m_NormalActionsCallbackInterface.OnMove;
|
|
@Move.performed -= m_Wrapper.m_NormalActionsCallbackInterface.OnMove;
|
|
@Move.canceled -= m_Wrapper.m_NormalActionsCallbackInterface.OnMove;
|
|
@Atk.started -= m_Wrapper.m_NormalActionsCallbackInterface.OnAtk;
|
|
@Atk.performed -= m_Wrapper.m_NormalActionsCallbackInterface.OnAtk;
|
|
@Atk.canceled -= m_Wrapper.m_NormalActionsCallbackInterface.OnAtk;
|
|
@Jump.started -= m_Wrapper.m_NormalActionsCallbackInterface.OnJump;
|
|
@Jump.performed -= m_Wrapper.m_NormalActionsCallbackInterface.OnJump;
|
|
@Jump.canceled -= m_Wrapper.m_NormalActionsCallbackInterface.OnJump;
|
|
@Interact.started -= m_Wrapper.m_NormalActionsCallbackInterface.OnInteract;
|
|
@Interact.performed -= m_Wrapper.m_NormalActionsCallbackInterface.OnInteract;
|
|
@Interact.canceled -= m_Wrapper.m_NormalActionsCallbackInterface.OnInteract;
|
|
}
|
|
m_Wrapper.m_NormalActionsCallbackInterface = instance;
|
|
if (instance != null)
|
|
{
|
|
@Move.started += instance.OnMove;
|
|
@Move.performed += instance.OnMove;
|
|
@Move.canceled += instance.OnMove;
|
|
@Atk.started += instance.OnAtk;
|
|
@Atk.performed += instance.OnAtk;
|
|
@Atk.canceled += instance.OnAtk;
|
|
@Jump.started += instance.OnJump;
|
|
@Jump.performed += instance.OnJump;
|
|
@Jump.canceled += instance.OnJump;
|
|
@Interact.started += instance.OnInteract;
|
|
@Interact.performed += instance.OnInteract;
|
|
@Interact.canceled += instance.OnInteract;
|
|
}
|
|
}
|
|
}
|
|
public NormalActions @Normal => new NormalActions(this);
|
|
|
|
// Null
|
|
private readonly InputActionMap m_Null;
|
|
private INullActions m_NullActionsCallbackInterface;
|
|
private readonly InputAction m_Null_Newaction;
|
|
public struct NullActions
|
|
{
|
|
private @PlayerC m_Wrapper;
|
|
public NullActions(@PlayerC wrapper) { m_Wrapper = wrapper; }
|
|
public InputAction @Newaction => m_Wrapper.m_Null_Newaction;
|
|
public InputActionMap Get() { return m_Wrapper.m_Null; }
|
|
public void Enable() { Get().Enable(); }
|
|
public void Disable() { Get().Disable(); }
|
|
public bool enabled => Get().enabled;
|
|
public static implicit operator InputActionMap(NullActions set) { return set.Get(); }
|
|
public void SetCallbacks(INullActions instance)
|
|
{
|
|
if (m_Wrapper.m_NullActionsCallbackInterface != null)
|
|
{
|
|
@Newaction.started -= m_Wrapper.m_NullActionsCallbackInterface.OnNewaction;
|
|
@Newaction.performed -= m_Wrapper.m_NullActionsCallbackInterface.OnNewaction;
|
|
@Newaction.canceled -= m_Wrapper.m_NullActionsCallbackInterface.OnNewaction;
|
|
}
|
|
m_Wrapper.m_NullActionsCallbackInterface = instance;
|
|
if (instance != null)
|
|
{
|
|
@Newaction.started += instance.OnNewaction;
|
|
@Newaction.performed += instance.OnNewaction;
|
|
@Newaction.canceled += instance.OnNewaction;
|
|
}
|
|
}
|
|
}
|
|
public NullActions @Null => new NullActions(this);
|
|
private int m_NormalSchemeIndex = -1;
|
|
public InputControlScheme NormalScheme
|
|
{
|
|
get
|
|
{
|
|
if (m_NormalSchemeIndex == -1) m_NormalSchemeIndex = asset.FindControlSchemeIndex("Normal");
|
|
return asset.controlSchemes[m_NormalSchemeIndex];
|
|
}
|
|
}
|
|
public interface INormalActions
|
|
{
|
|
void OnMove(InputAction.CallbackContext context);
|
|
void OnAtk(InputAction.CallbackContext context);
|
|
void OnJump(InputAction.CallbackContext context);
|
|
void OnInteract(InputAction.CallbackContext context);
|
|
}
|
|
public interface INullActions
|
|
{
|
|
void OnNewaction(InputAction.CallbackContext context);
|
|
}
|
|
}
|