use the new input system

master
Jordan Orelli 5 years ago
parent 315a138693
commit 485dfd2dff

@ -0,0 +1,253 @@
{
"name": "PlayerControls",
"maps": [
{
"name": "Gameplay",
"id": "0f158696-2993-40ed-bce5-2f0a3a29093a",
"actions": [
{
"name": "Move",
"type": "Value",
"id": "e8180706-4a99-4369-be61-f6804d26ed96",
"expectedControlType": "Vector2",
"processors": "",
"interactions": ""
},
{
"name": "Jump",
"type": "Button",
"id": "793c236d-8124-4373-8291-9d5c5a7c2bb2",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
},
{
"name": "Dash",
"type": "Button",
"id": "273f58db-399e-4985-9296-8a90e89d27f1",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
}
],
"bindings": [
{
"name": "",
"id": "1128cb0a-0dc3-4408-88a0-4afe1f6c82ec",
"path": "<Gamepad>/leftStick",
"interactions": "",
"processors": "",
"groups": "Gamepad",
"action": "Move",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "WASD",
"id": "7c390b91-0e17-4d79-b221-7edc5c22a9b8",
"path": "2DVector",
"interactions": "",
"processors": "",
"groups": "",
"action": "Move",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "up",
"id": "5de67ac2-2f9e-43c9-812e-294f10f93ed7",
"path": "<Keyboard>/w",
"interactions": "",
"processors": "",
"groups": "Keyboard",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "up",
"id": "7783fbd1-6f70-48a3-86b7-7dc7722897a9",
"path": "<Keyboard>/upArrow",
"interactions": "",
"processors": "",
"groups": "Keyboard",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "down",
"id": "4da5e308-3b71-49ca-898f-88cf08fe125d",
"path": "<Keyboard>/s",
"interactions": "",
"processors": "",
"groups": "Keyboard",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "down",
"id": "75f24288-3f1d-441b-95a9-422d134c9401",
"path": "<Keyboard>/downArrow",
"interactions": "",
"processors": "",
"groups": "Keyboard",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "left",
"id": "c16d1724-6adb-4d58-afe1-050a1b75caea",
"path": "<Keyboard>/leftArrow",
"interactions": "",
"processors": "",
"groups": "Keyboard",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "left",
"id": "3a35eeeb-c487-4414-9760-09142bfd3d9a",
"path": "<Keyboard>/a",
"interactions": "",
"processors": "",
"groups": "Keyboard",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "right",
"id": "cc33d0ff-c955-44ad-a2be-2b439cc1ff1a",
"path": "<Keyboard>/rightArrow",
"interactions": "",
"processors": "",
"groups": "Keyboard",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "right",
"id": "cf081bb3-ee82-45b7-9a85-559ba87dd315",
"path": "<Keyboard>/d",
"interactions": "",
"processors": "",
"groups": "Keyboard",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "",
"id": "c516442b-3679-48e0-8bff-c6e19902c800",
"path": "<Gamepad>/buttonSouth",
"interactions": "",
"processors": "",
"groups": "Gamepad",
"action": "Jump",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "887c5bef-ae6c-474b-b728-b698e378ae64",
"path": "<Keyboard>/space",
"interactions": "",
"processors": "",
"groups": "Keyboard",
"action": "Jump",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "5cf7e53a-e237-414a-aebf-f38fef6c909b",
"path": "<Gamepad>/buttonWest",
"interactions": "",
"processors": "",
"groups": "Gamepad",
"action": "Dash",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "68b3b805-a0ef-400d-9157-065113e0a91f",
"path": "<Keyboard>/enter",
"interactions": "",
"processors": "",
"groups": "Keyboard",
"action": "Dash",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "92afca33-2b86-429e-9d5d-4a8603f9fc8c",
"path": "<Keyboard>/shift",
"interactions": "",
"processors": "",
"groups": "Keyboard",
"action": "Dash",
"isComposite": false,
"isPartOfComposite": false
}
]
},
{
"name": "Menu",
"id": "012e31ca-c196-451a-b125-32625b69fd0e",
"actions": [
{
"name": "New action",
"type": "Button",
"id": "70c541e9-6f8e-443e-b124-26e8a922b42f",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
}
],
"bindings": [
{
"name": "",
"id": "5ac4cec0-e0e2-4381-99ca-31453af200c0",
"path": "",
"interactions": "",
"processors": "",
"groups": "",
"action": "New action",
"isComposite": false,
"isPartOfComposite": false
}
]
}
],
"controlSchemes": [
{
"name": "Gamepad",
"bindingGroup": "Gamepad",
"devices": [
{
"devicePath": "<Gamepad>",
"isOptional": false,
"isOR": false
}
]
},
{
"name": "Keyboard",
"bindingGroup": "Keyboard",
"devices": [
{
"devicePath": "<Keyboard>",
"isOptional": false,
"isOR": false
}
]
}
]
}

@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 135902785b70322458e3662c17478e1d
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
generateWrapperCode: 1
wrapperCodePath: Assets/Scripts/PlayerControls.cs
wrapperClassName:
wrapperCodeNamespace:

@ -159,6 +159,54 @@ MonoBehaviour:
tracerPrefab: {fileID: 2438817463505096557, guid: 76ce4ec4aba832343abb5a3c19e66b7c, tracerPrefab: {fileID: 2438817463505096557, guid: 76ce4ec4aba832343abb5a3c19e66b7c,
type: 3} type: 3}
dashIndicator: {fileID: 3504191955490326659} dashIndicator: {fileID: 3504191955490326659}
moveAction:
m_Name: Move
m_Type: 0
m_ExpectedControlType:
m_Id: ad4acdfe-fdb1-4bba-aaee-fd23b58c9e76
m_Processors:
m_Interactions:
m_SingletonActionBindings:
- m_Name:
m_Id: a136d531-716d-40df-bf2c-d970a579bfb2
m_Path: <Gamepad>/leftStick
m_Interactions:
m_Processors:
m_Groups:
m_Action: Move
m_Flags: 0
jumpAction:
m_Name: Jump
m_Type: 0
m_ExpectedControlType:
m_Id: 90cb081e-cdb8-497b-bbf1-8731dc964572
m_Processors:
m_Interactions:
m_SingletonActionBindings:
- m_Name:
m_Id: 49bfcfda-05b6-4d6d-acef-7105797c2c76
m_Path: <Gamepad>/buttonSouth
m_Interactions:
m_Processors:
m_Groups:
m_Action: Jump
m_Flags: 0
dashAction:
m_Name: Dash
m_Type: 0
m_ExpectedControlType:
m_Id: 3a2b1052-20a3-4b83-ad55-3b4df6265ed0
m_Processors:
m_Interactions:
m_SingletonActionBindings:
- m_Name:
m_Id: 26ac24c7-89f8-431a-a81a-14dff12d2862
m_Path: <Gamepad>/buttonWest
m_Interactions:
m_Processors:
m_Groups:
m_Action: Dash
m_Flags: 0
jumpState: 0 jumpState: 0
jumpDirection: 0 jumpDirection: 0
jumpCount: 0 jumpCount: 0

@ -1926,7 +1926,6 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 247789440} - component: {fileID: 247789440}
- component: {fileID: 247789439} - component: {fileID: 247789439}
- component: {fileID: 247789438}
m_Layer: 0 m_Layer: 0
m_Name: EventSystem m_Name: EventSystem
m_TagString: Untagged m_TagString: Untagged
@ -1934,25 +1933,6 @@ GameObject:
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!114 &247789438
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 247789437}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &247789439 --- !u!114 &247789439
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

@ -2,6 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
[RequireComponent(typeof(MoveController))] [RequireComponent(typeof(MoveController))]
[RequireComponent(typeof(BoxCollider2D))] [RequireComponent(typeof(BoxCollider2D))]
@ -23,6 +25,8 @@ public class PlayerController : MonoBehaviour {
public GameObject tracerPrefab; public GameObject tracerPrefab;
public GameObject dashIndicator; public GameObject dashIndicator;
public PlayerControls controls;
// this has to be public to be readable by the display, which is a code // this has to be public to be readable by the display, which is a code
// smell. // smell.
public JumpState jumpState; public JumpState jumpState;
@ -41,17 +45,29 @@ public class PlayerController : MonoBehaviour {
private float velocityXSmoothing; private float velocityXSmoothing;
void Start() { void Start() {
// Debug.Log("Creating new controls in Start!");
// controls = new PlayerControls();
setJumpState(JumpState.Falling); setJumpState(JumpState.Falling);
moveController = GetComponent<MoveController>(); moveController = GetComponent<MoveController>();
gravity = -(2* jumpHeight) / Mathf.Pow(timeToJumpApex, 2); gravity = -(2* jumpHeight) / Mathf.Pow(timeToJumpApex, 2);
jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex; jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
} }
void Awake() {
Debug.Log("Creating new controls in Awake!");
controls = new PlayerControls();
}
void Update() { void Update() {
InputActionPhase jumpPhase = controls.Gameplay.Jump.phase;
bool jumpTriggered = controls.Gameplay.Jump.triggered;
// Debug.LogFormat("Jump Phase: {0} Triggered: {1}", jumpPhase, jumpTriggered);
GameObject tracerObj = Instantiate(tracerPrefab, transform.position, Quaternion.identity); GameObject tracerObj = Instantiate(tracerPrefab, transform.position, Quaternion.identity);
TracerDot tracer = tracerObj.GetComponent<TracerDot>(); TracerDot tracer = tracerObj.GetComponent<TracerDot>();
Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")); Vector2 input = controls.Gameplay.Move.ReadValue<Vector2>();
// Vector2 input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
float targetX = input.x * moveSpeed; float targetX = input.x * moveSpeed;
if (Mathf.Abs(input.x) < 0.1) { if (Mathf.Abs(input.x) < 0.1) {
targetX = 0; targetX = 0;
@ -72,7 +88,8 @@ public class PlayerController : MonoBehaviour {
if (dash()) { if (dash()) {
break; break;
} else if (Input.GetButton("Jump")) { } else if (controls.Gameplay.Jump.phase == InputActionPhase.Started) {
// } else if (Input.GetButton("Jump")) {
velocity.y = jumpVelocity; velocity.y = jumpVelocity;
if (input.x >= 0.25f) { if (input.x >= 0.25f) {
velocity.x = moveSpeed*maxForwardJumpBoost; velocity.x = moveSpeed*maxForwardJumpBoost;
@ -114,7 +131,8 @@ public class PlayerController : MonoBehaviour {
if (dash()) { if (dash()) {
break; break;
} else if (Input.GetButtonDown("Jump") && jumpCount < maxJumps) { // } else if (Input.GetButtonDown("Jump") && jumpCount < maxJumps) {
} else if (controls.Gameplay.Jump.triggered && jumpCount < maxJumps) {
velocity.y = jumpVelocity; velocity.y = jumpVelocity;
if (input.x >= 0.25f) { if (input.x >= 0.25f) {
velocity.x = moveSpeed*maxForwardJumpBoost; velocity.x = moveSpeed*maxForwardJumpBoost;
@ -125,7 +143,8 @@ public class PlayerController : MonoBehaviour {
} }
setJumpState(JumpState.Ascending); setJumpState(JumpState.Ascending);
break; break;
} else if (Input.GetButton("Jump")) { // } else if (Input.GetButton("Jump")) {
} else if (controls.Gameplay.Jump.phase == InputActionPhase.Started) {
float jumpDrag = jumpVelocity * dragCoefficient; float jumpDrag = jumpVelocity * dragCoefficient;
if (n <= 0.7) { if (n <= 0.7) {
jumpDrag = 0; jumpDrag = 0;
@ -164,7 +183,8 @@ public class PlayerController : MonoBehaviour {
// frame, we should zero out the velocity to float instead. // frame, we should zero out the velocity to float instead.
if (initialVelocity.y >= 0 && velocity.y <= 0) { if (initialVelocity.y >= 0 && velocity.y <= 0) {
velocity.y = 0; velocity.y = 0;
if (wasHoldingJump && Input.GetButton("Jump")) { // if (wasHoldingJump && Input.GetButton("Jump")) {
if (wasHoldingJump && controls.Gameplay.Jump.phase == InputActionPhase.Started) {
apexTime = maxApexTime; apexTime = maxApexTime;
} }
setJumpState(JumpState.Apex); setJumpState(JumpState.Apex);
@ -176,7 +196,8 @@ public class PlayerController : MonoBehaviour {
if (dash()) { if (dash()) {
break; break;
} else if (Input.GetButtonDown("Jump") && jumpCount < maxJumps) { // } else if (Input.GetButtonDown("Jump") && jumpCount < maxJumps) {
} else if (controls.Gameplay.Jump.triggered && jumpCount < maxJumps) {
velocity.y = jumpVelocity; velocity.y = jumpVelocity;
if (input.x >= 0.25f) { if (input.x >= 0.25f) {
velocity.x = moveSpeed*maxForwardJumpBoost; velocity.x = moveSpeed*maxForwardJumpBoost;
@ -214,7 +235,8 @@ public class PlayerController : MonoBehaviour {
case JumpState.Descending: case JumpState.Descending:
tracer.color = Color.yellow; tracer.color = Color.yellow;
if (Input.GetButtonDown("Jump") && jumpCount < maxJumps) { // if (Input.GetButtonDown("Jump") && jumpCount < maxJumps) {
if (controls.Gameplay.Jump.triggered && jumpCount < maxJumps) {
velocity.y = jumpVelocity; velocity.y = jumpVelocity;
if (input.x >= 0.25f) { if (input.x >= 0.25f) {
velocity.x = moveSpeed*maxForwardJumpBoost; velocity.x = moveSpeed*maxForwardJumpBoost;
@ -251,7 +273,8 @@ public class PlayerController : MonoBehaviour {
if (dash()) { if (dash()) {
break; break;
} else if (Input.GetButtonDown("Jump")) { // } else if (Input.GetButtonDown("Jump")) {
} else if (controls.Gameplay.Jump.triggered) {
setJumpState(JumpState.Ascending); setJumpState(JumpState.Ascending);
velocity.y = jumpVelocity; velocity.y = jumpVelocity;
} else { } else {
@ -267,7 +290,8 @@ public class PlayerController : MonoBehaviour {
case JumpState.Falling: case JumpState.Falling:
tracer.color = Color.grey; tracer.color = Color.grey;
if (Input.GetButtonDown("Jump") && jumpCount < maxJumps) { // if (Input.GetButtonDown("Jump") && jumpCount < maxJumps) {
if (controls.Gameplay.Jump.triggered && jumpCount < maxJumps) {
velocity.y = jumpVelocity; velocity.y = jumpVelocity;
if (input.x >= 0.25f) { if (input.x >= 0.25f) {
velocity.x = moveSpeed*maxForwardJumpBoost; velocity.x = moveSpeed*maxForwardJumpBoost;
@ -309,7 +333,8 @@ public class PlayerController : MonoBehaviour {
if (jumpState != JumpState.Grounded && moveController.isGrounded) { if (jumpState != JumpState.Grounded && moveController.isGrounded) {
setJumpState(JumpState.Grounded); setJumpState(JumpState.Grounded);
} }
wasHoldingJump = Input.GetButton("Jump"); // wasHoldingJump = Input.GetButton("Jump");
wasHoldingJump = controls.Gameplay.Jump.phase == InputActionPhase.Started;
CheckCollisions(); CheckCollisions();
} }
@ -343,6 +368,20 @@ public class PlayerController : MonoBehaviour {
} }
} }
public void OnEnable() {
Debug.Log("Enabling the controls!");
controls.Enable();
controls.Gameplay.Enable();
controls.Gameplay.Jump.Enable();
}
public void OnDisable() {
Debug.Log("Disabling the controls!");
controls.Disable();
controls.Gameplay.Disable();
controls.Gameplay.Jump.Disable();
}
void OnDestroy() { void OnDestroy() {
} }
@ -353,7 +392,8 @@ public class PlayerController : MonoBehaviour {
} }
bool dash() { bool dash() {
if (!Input.GetButtonDown("Fire1")) { // if (!Input.GetButtonDown("Fire1")) {
if (!controls.Gameplay.Dash.triggered) {
return false; return false;
} }

@ -0,0 +1,430 @@
// GENERATED AUTOMATICALLY FROM 'Assets/PlayerControls.inputactions'
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
public class @PlayerControls : IInputActionCollection, IDisposable
{
public InputActionAsset asset { get; }
public @PlayerControls()
{
asset = InputActionAsset.FromJson(@"{
""name"": ""PlayerControls"",
""maps"": [
{
""name"": ""Gameplay"",
""id"": ""0f158696-2993-40ed-bce5-2f0a3a29093a"",
""actions"": [
{
""name"": ""Move"",
""type"": ""Value"",
""id"": ""e8180706-4a99-4369-be61-f6804d26ed96"",
""expectedControlType"": ""Vector2"",
""processors"": """",
""interactions"": """"
},
{
""name"": ""Jump"",
""type"": ""Button"",
""id"": ""793c236d-8124-4373-8291-9d5c5a7c2bb2"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """"
},
{
""name"": ""Dash"",
""type"": ""Button"",
""id"": ""273f58db-399e-4985-9296-8a90e89d27f1"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """"
}
],
""bindings"": [
{
""name"": """",
""id"": ""1128cb0a-0dc3-4408-88a0-4afe1f6c82ec"",
""path"": ""<Gamepad>/leftStick"",
""interactions"": """",
""processors"": """",
""groups"": ""Gamepad"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": ""WASD"",
""id"": ""7c390b91-0e17-4d79-b221-7edc5c22a9b8"",
""path"": ""2DVector"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Move"",
""isComposite"": true,
""isPartOfComposite"": false
},
{
""name"": ""up"",
""id"": ""5de67ac2-2f9e-43c9-812e-294f10f93ed7"",
""path"": ""<Keyboard>/w"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""up"",
""id"": ""7783fbd1-6f70-48a3-86b7-7dc7722897a9"",
""path"": ""<Keyboard>/upArrow"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""down"",
""id"": ""4da5e308-3b71-49ca-898f-88cf08fe125d"",
""path"": ""<Keyboard>/s"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""down"",
""id"": ""75f24288-3f1d-441b-95a9-422d134c9401"",
""path"": ""<Keyboard>/downArrow"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""left"",
""id"": ""c16d1724-6adb-4d58-afe1-050a1b75caea"",
""path"": ""<Keyboard>/leftArrow"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""left"",
""id"": ""3a35eeeb-c487-4414-9760-09142bfd3d9a"",
""path"": ""<Keyboard>/a"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""right"",
""id"": ""cc33d0ff-c955-44ad-a2be-2b439cc1ff1a"",
""path"": ""<Keyboard>/rightArrow"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""right"",
""id"": ""cf081bb3-ee82-45b7-9a85-559ba87dd315"",
""path"": ""<Keyboard>/d"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": """",
""id"": ""c516442b-3679-48e0-8bff-c6e19902c800"",
""path"": ""<Gamepad>/buttonSouth"",
""interactions"": """",
""processors"": """",
""groups"": ""Gamepad"",
""action"": ""Jump"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""887c5bef-ae6c-474b-b728-b698e378ae64"",
""path"": ""<Keyboard>/space"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard"",
""action"": ""Jump"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""5cf7e53a-e237-414a-aebf-f38fef6c909b"",
""path"": ""<Gamepad>/buttonWest"",
""interactions"": """",
""processors"": """",
""groups"": ""Gamepad"",
""action"": ""Dash"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""68b3b805-a0ef-400d-9157-065113e0a91f"",
""path"": ""<Keyboard>/enter"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard"",
""action"": ""Dash"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""92afca33-2b86-429e-9d5d-4a8603f9fc8c"",
""path"": ""<Keyboard>/shift"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard"",
""action"": ""Dash"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
},
{
""name"": ""Menu"",
""id"": ""012e31ca-c196-451a-b125-32625b69fd0e"",
""actions"": [
{
""name"": ""New action"",
""type"": ""Button"",
""id"": ""70c541e9-6f8e-443e-b124-26e8a922b42f"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """"
}
],
""bindings"": [
{
""name"": """",
""id"": ""5ac4cec0-e0e2-4381-99ca-31453af200c0"",
""path"": """",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""New action"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
],
""controlSchemes"": [
{
""name"": ""Gamepad"",
""bindingGroup"": ""Gamepad"",
""devices"": [
{
""devicePath"": ""<Gamepad>"",
""isOptional"": false,
""isOR"": false
}
]
},
{
""name"": ""Keyboard"",
""bindingGroup"": ""Keyboard"",
""devices"": [
{
""devicePath"": ""<Keyboard>"",
""isOptional"": false,
""isOR"": false
}
]
}
]
}");
// 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);
m_Gameplay_Dash = m_Gameplay.FindAction("Dash", throwIfNotFound: true);
// Menu
m_Menu = asset.FindActionMap("Menu", throwIfNotFound: true);
m_Menu_Newaction = m_Menu.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();
}
// Gameplay
private readonly InputActionMap m_Gameplay;
private IGameplayActions m_GameplayActionsCallbackInterface;
private readonly InputAction m_Gameplay_Move;
private readonly InputAction m_Gameplay_Jump;
private readonly InputAction m_Gameplay_Dash;
public struct GameplayActions
{
private @PlayerControls m_Wrapper;
public GameplayActions(@PlayerControls wrapper) { m_Wrapper = wrapper; }
public InputAction @Move => m_Wrapper.m_Gameplay_Move;
public InputAction @Jump => m_Wrapper.m_Gameplay_Jump;
public InputAction @Dash => m_Wrapper.m_Gameplay_Dash;
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;
@Dash.started -= m_Wrapper.m_GameplayActionsCallbackInterface.OnDash;
@Dash.performed -= m_Wrapper.m_GameplayActionsCallbackInterface.OnDash;
@Dash.canceled -= m_Wrapper.m_GameplayActionsCallbackInterface.OnDash;
}
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;
@Dash.started += instance.OnDash;
@Dash.performed += instance.OnDash;
@Dash.canceled += instance.OnDash;
}
}
}
public GameplayActions @Gameplay => new GameplayActions(this);
// Menu
private readonly InputActionMap m_Menu;
private IMenuActions m_MenuActionsCallbackInterface;
private readonly InputAction m_Menu_Newaction;
public struct MenuActions
{
private @PlayerControls m_Wrapper;
public MenuActions(@PlayerControls wrapper) { m_Wrapper = wrapper; }
public InputAction @Newaction => m_Wrapper.m_Menu_Newaction;
public InputActionMap Get() { return m_Wrapper.m_Menu; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(MenuActions set) { return set.Get(); }
public void SetCallbacks(IMenuActions instance)
{
if (m_Wrapper.m_MenuActionsCallbackInterface != null)
{
@Newaction.started -= m_Wrapper.m_MenuActionsCallbackInterface.OnNewaction;
@Newaction.performed -= m_Wrapper.m_MenuActionsCallbackInterface.OnNewaction;
@Newaction.canceled -= m_Wrapper.m_MenuActionsCallbackInterface.OnNewaction;
}
m_Wrapper.m_MenuActionsCallbackInterface = instance;
if (instance != null)
{
@Newaction.started += instance.OnNewaction;
@Newaction.performed += instance.OnNewaction;
@Newaction.canceled += instance.OnNewaction;
}
}
}
public MenuActions @Menu => new MenuActions(this);
private int m_GamepadSchemeIndex = -1;
public InputControlScheme GamepadScheme
{
get
{
if (m_GamepadSchemeIndex == -1) m_GamepadSchemeIndex = asset.FindControlSchemeIndex("Gamepad");
return asset.controlSchemes[m_GamepadSchemeIndex];
}
}
private int m_KeyboardSchemeIndex = -1;
public InputControlScheme KeyboardScheme
{
get
{
if (m_KeyboardSchemeIndex == -1) m_KeyboardSchemeIndex = asset.FindControlSchemeIndex("Keyboard");
return asset.controlSchemes[m_KeyboardSchemeIndex];
}
}
public interface IGameplayActions
{
void OnMove(InputAction.CallbackContext context);
void OnJump(InputAction.CallbackContext context);
void OnDash(InputAction.CallbackContext context);
}
public interface IMenuActions
{
void OnNewaction(InputAction.CallbackContext context);
}
}

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9809c83005b646645b5a20fe90d346e5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -7,6 +7,7 @@
"com.unity.collab-proxy": "1.2.16", "com.unity.collab-proxy": "1.2.16",
"com.unity.ide.rider": "1.1.4", "com.unity.ide.rider": "1.1.4",
"com.unity.ide.vscode": "1.1.3", "com.unity.ide.vscode": "1.1.3",
"com.unity.inputsystem": "1.0.0",
"com.unity.multiplayer-hlapi": "1.0.4", "com.unity.multiplayer-hlapi": "1.0.4",
"com.unity.purchasing": "2.0.6", "com.unity.purchasing": "2.0.6",
"com.unity.quicksearch": "1.6.0-preview.6", "com.unity.quicksearch": "1.6.0-preview.6",

@ -684,6 +684,6 @@ PlayerSettings:
projectName: projectName:
organizationId: organizationId:
cloudEnabled: 0 cloudEnabled: 0
enableNativePlatformBackendsForNewInputSystem: 0 enableNativePlatformBackendsForNewInputSystem: 1
disableOldInputManagerSupport: 0 disableOldInputManagerSupport: 1
legacyClampBlendShapeWeights: 0 legacyClampBlendShapeWeights: 0

@ -16,7 +16,7 @@ TagManager:
- Player - Player
- -
- Level - Level
- - Platform
- -
- -
- -

Loading…
Cancel
Save