From 41def44651b5a7c9e917395fad5e7b480640a3a2 Mon Sep 17 00:00:00 2001 From: SmallFox <2806143047@qq.com> Date: Thu, 14 May 2026 21:17:29 +0800 Subject: Movement完工 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 写完了移动,准备开工相机视角 --- Assets/Scripts/InputSystem/PlayerControls.cs | 252 +++++++++++++++++++++ Assets/Scripts/InputSystem/PlayerControls.cs.meta | 11 + .../InputSystem/PlayerControls.inputactions | 109 +++++++++ .../InputSystem/PlayerControls.inputactions.meta | 14 ++ 4 files changed, 386 insertions(+) create mode 100644 Assets/Scripts/InputSystem/PlayerControls.cs create mode 100644 Assets/Scripts/InputSystem/PlayerControls.cs.meta create mode 100644 Assets/Scripts/InputSystem/PlayerControls.inputactions create mode 100644 Assets/Scripts/InputSystem/PlayerControls.inputactions.meta (limited to 'Assets/Scripts/InputSystem') diff --git a/Assets/Scripts/InputSystem/PlayerControls.cs b/Assets/Scripts/InputSystem/PlayerControls.cs new file mode 100644 index 0000000..71ef71f --- /dev/null +++ b/Assets/Scripts/InputSystem/PlayerControls.cs @@ -0,0 +1,252 @@ +//------------------------------------------------------------------------------ +// +// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator +// version 1.7.0 +// from Assets/Scripts/InputSystem/PlayerControls.inputactions +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine.InputSystem; +using UnityEngine.InputSystem.Utilities; + +public partial class @PlayerControls: IInputActionCollection2, IDisposable +{ + public InputActionAsset asset { get; } + public @PlayerControls() + { + asset = InputActionAsset.FromJson(@"{ + ""name"": ""PlayerControls"", + ""maps"": [ + { + ""name"": ""Player Movement"", + ""id"": ""cfb355ad-e0aa-4dad-9111-af6e3f1271b2"", + ""actions"": [ + { + ""name"": ""Movement"", + ""type"": ""PassThrough"", + ""id"": ""1ab3b457-9558-4d1c-b580-1b6a7d3cbd45"", + ""expectedControlType"": ""Vector2"", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": false + }, + { + ""name"": ""Camera"", + ""type"": ""Value"", + ""id"": ""bb5b6b4b-5b42-4192-a498-10356a2b125a"", + ""expectedControlType"": ""Vector2"", + ""processors"": """", + ""interactions"": """", + ""initialStateCheck"": true + } + ], + ""bindings"": [ + { + ""name"": ""WASD"", + ""id"": ""d8a77518-37e0-4dd9-8c87-9a6f159ed71b"", + ""path"": ""2DVector"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Movement"", + ""isComposite"": true, + ""isPartOfComposite"": false + }, + { + ""name"": ""up"", + ""id"": ""4eb43c7b-9a1d-4f13-877b-6b3acf19ad17"", + ""path"": ""/w"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Movement"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""down"", + ""id"": ""2228edfc-964a-42e3-b1ba-53aebb8f0d5f"", + ""path"": ""/s"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Movement"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""left"", + ""id"": ""a35a6c7a-e429-4cb5-90d4-edf345cd188d"", + ""path"": ""/a"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Movement"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": ""right"", + ""id"": ""c9d8817d-167d-4526-b441-3bfd52363503"", + ""path"": ""/d"", + ""interactions"": """", + ""processors"": """", + ""groups"": """", + ""action"": ""Movement"", + ""isComposite"": false, + ""isPartOfComposite"": true + }, + { + ""name"": """", + ""id"": ""d0d72338-edcb-44b9-a675-823b93f06cc0"", + ""path"": ""/rightStick"", + ""interactions"": """", + ""processors"": ""StickDeadzone"", + ""groups"": """", + ""action"": ""Camera"", + ""isComposite"": false, + ""isPartOfComposite"": false + }, + { + ""name"": """", + ""id"": ""b1f249ca-76f5-4443-85fe-eff12e361675"", + ""path"": ""/delta"", + ""interactions"": """", + ""processors"": ""NormalizeVector2"", + ""groups"": """", + ""action"": ""Camera"", + ""isComposite"": false, + ""isPartOfComposite"": false + } + ] + } + ], + ""controlSchemes"": [] +}"); + // Player Movement + m_PlayerMovement = asset.FindActionMap("Player Movement", throwIfNotFound: true); + m_PlayerMovement_Movement = m_PlayerMovement.FindAction("Movement", throwIfNotFound: true); + m_PlayerMovement_Camera = m_PlayerMovement.FindAction("Camera", throwIfNotFound: true); + } + + public void Dispose() + { + UnityEngine.Object.Destroy(asset); + } + + public InputBinding? bindingMask + { + get => asset.bindingMask; + set => asset.bindingMask = value; + } + + public ReadOnlyArray? devices + { + get => asset.devices; + set => asset.devices = value; + } + + public ReadOnlyArray controlSchemes => asset.controlSchemes; + + public bool Contains(InputAction action) + { + return asset.Contains(action); + } + + public IEnumerator GetEnumerator() + { + return asset.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Enable() + { + asset.Enable(); + } + + public void Disable() + { + asset.Disable(); + } + + public IEnumerable 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); + } + + // Player Movement + private readonly InputActionMap m_PlayerMovement; + private List m_PlayerMovementActionsCallbackInterfaces = new List(); + private readonly InputAction m_PlayerMovement_Movement; + private readonly InputAction m_PlayerMovement_Camera; + public struct PlayerMovementActions + { + private @PlayerControls m_Wrapper; + public PlayerMovementActions(@PlayerControls wrapper) { m_Wrapper = wrapper; } + public InputAction @Movement => m_Wrapper.m_PlayerMovement_Movement; + public InputAction @Camera => m_Wrapper.m_PlayerMovement_Camera; + public InputActionMap Get() { return m_Wrapper.m_PlayerMovement; } + public void Enable() { Get().Enable(); } + public void Disable() { Get().Disable(); } + public bool enabled => Get().enabled; + public static implicit operator InputActionMap(PlayerMovementActions set) { return set.Get(); } + public void AddCallbacks(IPlayerMovementActions instance) + { + if (instance == null || m_Wrapper.m_PlayerMovementActionsCallbackInterfaces.Contains(instance)) return; + m_Wrapper.m_PlayerMovementActionsCallbackInterfaces.Add(instance); + @Movement.started += instance.OnMovement; + @Movement.performed += instance.OnMovement; + @Movement.canceled += instance.OnMovement; + @Camera.started += instance.OnCamera; + @Camera.performed += instance.OnCamera; + @Camera.canceled += instance.OnCamera; + } + + private void UnregisterCallbacks(IPlayerMovementActions instance) + { + @Movement.started -= instance.OnMovement; + @Movement.performed -= instance.OnMovement; + @Movement.canceled -= instance.OnMovement; + @Camera.started -= instance.OnCamera; + @Camera.performed -= instance.OnCamera; + @Camera.canceled -= instance.OnCamera; + } + + public void RemoveCallbacks(IPlayerMovementActions instance) + { + if (m_Wrapper.m_PlayerMovementActionsCallbackInterfaces.Remove(instance)) + UnregisterCallbacks(instance); + } + + public void SetCallbacks(IPlayerMovementActions instance) + { + foreach (var item in m_Wrapper.m_PlayerMovementActionsCallbackInterfaces) + UnregisterCallbacks(item); + m_Wrapper.m_PlayerMovementActionsCallbackInterfaces.Clear(); + AddCallbacks(instance); + } + } + public PlayerMovementActions @PlayerMovement => new PlayerMovementActions(this); + public interface IPlayerMovementActions + { + void OnMovement(InputAction.CallbackContext context); + void OnCamera(InputAction.CallbackContext context); + } +} diff --git a/Assets/Scripts/InputSystem/PlayerControls.cs.meta b/Assets/Scripts/InputSystem/PlayerControls.cs.meta new file mode 100644 index 0000000..7bccbc7 --- /dev/null +++ b/Assets/Scripts/InputSystem/PlayerControls.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8f290c6d6ff027e439a0eabfe764b011 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/InputSystem/PlayerControls.inputactions b/Assets/Scripts/InputSystem/PlayerControls.inputactions new file mode 100644 index 0000000..ed31d4a --- /dev/null +++ b/Assets/Scripts/InputSystem/PlayerControls.inputactions @@ -0,0 +1,109 @@ +{ + "name": "PlayerControls", + "maps": [ + { + "name": "Player Movement", + "id": "cfb355ad-e0aa-4dad-9111-af6e3f1271b2", + "actions": [ + { + "name": "Movement", + "type": "PassThrough", + "id": "1ab3b457-9558-4d1c-b580-1b6a7d3cbd45", + "expectedControlType": "Vector2", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, + { + "name": "Camera", + "type": "Value", + "id": "bb5b6b4b-5b42-4192-a498-10356a2b125a", + "expectedControlType": "Vector2", + "processors": "", + "interactions": "", + "initialStateCheck": true + } + ], + "bindings": [ + { + "name": "WASD", + "id": "d8a77518-37e0-4dd9-8c87-9a6f159ed71b", + "path": "2DVector", + "interactions": "", + "processors": "", + "groups": "", + "action": "Movement", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "up", + "id": "4eb43c7b-9a1d-4f13-877b-6b3acf19ad17", + "path": "/w", + "interactions": "", + "processors": "", + "groups": "", + "action": "Movement", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "down", + "id": "2228edfc-964a-42e3-b1ba-53aebb8f0d5f", + "path": "/s", + "interactions": "", + "processors": "", + "groups": "", + "action": "Movement", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "left", + "id": "a35a6c7a-e429-4cb5-90d4-edf345cd188d", + "path": "/a", + "interactions": "", + "processors": "", + "groups": "", + "action": "Movement", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "right", + "id": "c9d8817d-167d-4526-b441-3bfd52363503", + "path": "/d", + "interactions": "", + "processors": "", + "groups": "", + "action": "Movement", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "", + "id": "d0d72338-edcb-44b9-a675-823b93f06cc0", + "path": "/rightStick", + "interactions": "", + "processors": "StickDeadzone", + "groups": "", + "action": "Camera", + "isComposite": false, + "isPartOfComposite": false + }, + { + "name": "", + "id": "b1f249ca-76f5-4443-85fe-eff12e361675", + "path": "/delta", + "interactions": "", + "processors": "NormalizeVector2", + "groups": "", + "action": "Camera", + "isComposite": false, + "isPartOfComposite": false + } + ] + } + ], + "controlSchemes": [] +} \ No newline at end of file diff --git a/Assets/Scripts/InputSystem/PlayerControls.inputactions.meta b/Assets/Scripts/InputSystem/PlayerControls.inputactions.meta new file mode 100644 index 0000000..d54b310 --- /dev/null +++ b/Assets/Scripts/InputSystem/PlayerControls.inputactions.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: 951b38ef40b38c44cb85c66fdd40eccc +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3} + generateWrapperCode: 1 + wrapperCodePath: + wrapperClassName: + wrapperCodeNamespace: -- cgit