Updated PlayerController.cs

This commit is contained in:
OverflowNarhoym
2022-02-21 18:40:03 +01:00
parent b27aab9c9b
commit 1eb0cfa3de
19 changed files with 1137 additions and 21 deletions

292
Assets/Input/Player.cs Normal file
View File

@@ -0,0 +1,292 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
// version 1.3.0
// from Assets/Input/Player.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;
namespace Input
{
public partial class @PlayerInput : IInputActionCollection2, IDisposable
{
public InputActionAsset asset { get; }
public @PlayerInput()
{
asset = InputActionAsset.FromJson(@"{
""name"": ""Player"",
""maps"": [
{
""name"": ""PlayerControl"",
""id"": ""6b283d13-6660-4d53-8e92-97340d3e7e40"",
""actions"": [
{
""name"": ""Move"",
""type"": ""Button"",
""id"": ""d609b7bd-de59-47fe-be7c-eab846108ebb"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""Jump"",
""type"": ""Button"",
""id"": ""838b4154-0282-407c-860e-970ffb1a69dc"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
{
""name"": ""1D Axis Keyboard"",
""id"": ""f1eaf8e5-b149-4905-a8a9-121890ee136c"",
""path"": ""1DAxis"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Move"",
""isComposite"": true,
""isPartOfComposite"": false
},
{
""name"": ""negative"",
""id"": ""a9afa3f2-ec1f-430d-a41b-77d221b7d656"",
""path"": ""<Keyboard>/leftArrow"",
""interactions"": """",
""processors"": """",
""groups"": ""KeyBoard"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""positive"",
""id"": ""064aa7d7-b08b-4cea-915f-e225e5c62072"",
""path"": ""<Keyboard>/rightArrow"",
""interactions"": """",
""processors"": """",
""groups"": ""KeyBoard"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""1D Axis Gamepad"",
""id"": ""93eaa249-8b44-4767-b233-0ed70a500631"",
""path"": ""1DAxis"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Move"",
""isComposite"": true,
""isPartOfComposite"": false
},
{
""name"": ""negative"",
""id"": ""084c37a9-d0a1-4ffa-988b-301e97060e91"",
""path"": ""<Gamepad>/leftStick/left"",
""interactions"": """",
""processors"": """",
""groups"": ""Controller"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""positive"",
""id"": ""a0c7812a-cdf9-4a02-9394-ea1ea5bd3d37"",
""path"": ""<Gamepad>/leftStick/right"",
""interactions"": """",
""processors"": """",
""groups"": ""Controller"",
""action"": ""Move"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": """",
""id"": ""7e8fccb6-fdf3-48f1-a967-3ade3adf570a"",
""path"": ""<Keyboard>/space"",
""interactions"": """",
""processors"": """",
""groups"": ""KeyBoard"",
""action"": ""Jump"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""868cbe30-e640-4d8d-b818-a57529b316c8"",
""path"": ""<Gamepad>/buttonSouth"",
""interactions"": """",
""processors"": """",
""groups"": ""Controller"",
""action"": ""Jump"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
],
""controlSchemes"": [
{
""name"": ""Controller"",
""bindingGroup"": ""Controller"",
""devices"": [
{
""devicePath"": ""<Gamepad>"",
""isOptional"": false,
""isOR"": false
}
]
},
{
""name"": ""KeyBoard"",
""bindingGroup"": ""KeyBoard"",
""devices"": [
{
""devicePath"": ""<Keyboard>"",
""isOptional"": false,
""isOR"": false
}
]
}
]
}");
// PlayerControl
m_PlayerControl = asset.FindActionMap("PlayerControl", throwIfNotFound: true);
m_PlayerControl_Move = m_PlayerControl.FindAction("Move", throwIfNotFound: true);
m_PlayerControl_Jump = m_PlayerControl.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);
}
// PlayerControl
private readonly InputActionMap m_PlayerControl;
private IPlayerControlActions m_PlayerControlActionsCallbackInterface;
private readonly InputAction m_PlayerControl_Move;
private readonly InputAction m_PlayerControl_Jump;
public struct PlayerControlActions
{
private @PlayerInput m_Wrapper;
public PlayerControlActions(@PlayerInput wrapper) { m_Wrapper = wrapper; }
public InputAction @Move => m_Wrapper.m_PlayerControl_Move;
public InputAction @Jump => m_Wrapper.m_PlayerControl_Jump;
public InputActionMap Get() { return m_Wrapper.m_PlayerControl; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(PlayerControlActions set) { return set.Get(); }
public void SetCallbacks(IPlayerControlActions instance)
{
if (m_Wrapper.m_PlayerControlActionsCallbackInterface != null)
{
@Move.started -= m_Wrapper.m_PlayerControlActionsCallbackInterface.OnMove;
@Move.performed -= m_Wrapper.m_PlayerControlActionsCallbackInterface.OnMove;
@Move.canceled -= m_Wrapper.m_PlayerControlActionsCallbackInterface.OnMove;
@Jump.started -= m_Wrapper.m_PlayerControlActionsCallbackInterface.OnJump;
@Jump.performed -= m_Wrapper.m_PlayerControlActionsCallbackInterface.OnJump;
@Jump.canceled -= m_Wrapper.m_PlayerControlActionsCallbackInterface.OnJump;
}
m_Wrapper.m_PlayerControlActionsCallbackInterface = 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 PlayerControlActions @PlayerControl => new PlayerControlActions(this);
private int m_ControllerSchemeIndex = -1;
public InputControlScheme ControllerScheme
{
get
{
if (m_ControllerSchemeIndex == -1) m_ControllerSchemeIndex = asset.FindControlSchemeIndex("Controller");
return asset.controlSchemes[m_ControllerSchemeIndex];
}
}
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 IPlayerControlActions
{
void OnMove(InputAction.CallbackContext context);
void OnJump(InputAction.CallbackContext context);
}
}
}

View File

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

View File

@@ -0,0 +1,143 @@
{
"name": "Player",
"maps": [
{
"name": "PlayerControl",
"id": "6b283d13-6660-4d53-8e92-97340d3e7e40",
"actions": [
{
"name": "Move",
"type": "Button",
"id": "d609b7bd-de59-47fe-be7c-eab846108ebb",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "Jump",
"type": "Button",
"id": "838b4154-0282-407c-860e-970ffb1a69dc",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
{
"name": "1D Axis Keyboard",
"id": "f1eaf8e5-b149-4905-a8a9-121890ee136c",
"path": "1DAxis",
"interactions": "",
"processors": "",
"groups": "",
"action": "Move",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "negative",
"id": "a9afa3f2-ec1f-430d-a41b-77d221b7d656",
"path": "<Keyboard>/leftArrow",
"interactions": "",
"processors": "",
"groups": "KeyBoard",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "positive",
"id": "064aa7d7-b08b-4cea-915f-e225e5c62072",
"path": "<Keyboard>/rightArrow",
"interactions": "",
"processors": "",
"groups": "KeyBoard",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "1D Axis Gamepad",
"id": "93eaa249-8b44-4767-b233-0ed70a500631",
"path": "1DAxis",
"interactions": "",
"processors": "",
"groups": "",
"action": "Move",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "negative",
"id": "084c37a9-d0a1-4ffa-988b-301e97060e91",
"path": "<Gamepad>/leftStick/left",
"interactions": "",
"processors": "",
"groups": "Controller",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "positive",
"id": "a0c7812a-cdf9-4a02-9394-ea1ea5bd3d37",
"path": "<Gamepad>/leftStick/right",
"interactions": "",
"processors": "",
"groups": "Controller",
"action": "Move",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "",
"id": "7e8fccb6-fdf3-48f1-a967-3ade3adf570a",
"path": "<Keyboard>/space",
"interactions": "",
"processors": "",
"groups": "KeyBoard",
"action": "Jump",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "868cbe30-e640-4d8d-b818-a57529b316c8",
"path": "<Gamepad>/buttonSouth",
"interactions": "",
"processors": "",
"groups": "Controller",
"action": "Jump",
"isComposite": false,
"isPartOfComposite": false
}
]
}
],
"controlSchemes": [
{
"name": "Controller",
"bindingGroup": "Controller",
"devices": [
{
"devicePath": "<Gamepad>",
"isOptional": false,
"isOR": false
}
]
},
{
"name": "KeyBoard",
"bindingGroup": "KeyBoard",
"devices": [
{
"devicePath": "<Keyboard>",
"isOptional": false,
"isOR": false
}
]
}
]
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 95988d45e5b74ba4caed759a63cea55a
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
generateWrapperCode: 1
wrapperCodePath:
wrapperClassName: PlayerInput
wrapperCodeNamespace: Input