Adaug proiectul Unity

This commit is contained in:
2026-11-01 23:39:55 +02:00
parent cb14d9d37d
commit 863eac8f2c
23463 changed files with 5412601 additions and 0 deletions
@@ -0,0 +1,62 @@
using UnityEngine;
using UnityEngine.InputSystem;
//-----------------------------------------------------------------------
// Author: Colby-O
// File: InputManager.cs
//-----------------------------------------------------------------------
namespace ColbyO.VNTG.Example
{
[RequireComponent(typeof(PlayerInput))]
internal class InputManager : MonoBehaviour
{
[SerializeField] private PlayerInput _input;
private InputAction _moveAction;
private InputAction _lookAction;
public Vector2 RawMovement { get; private set; }
public Vector2 RawLook { get; private set; }
private void Awake()
{
if (!_input) _input = GetComponent<PlayerInput>();
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
_moveAction = _input.actions["Move"];
_lookAction = _input.actions["Look"];
_moveAction.performed += HandleMoveAction;
_lookAction.performed += HandleLookAction;
}
private void OnDestroy()
{
_moveAction.performed -= HandleMoveAction;
_lookAction.performed -= HandleLookAction;
}
private void HandleMoveAction(InputAction.CallbackContext e)
{
RawMovement = e.ReadValue<Vector2>();
}
private void HandleLookAction(InputAction.CallbackContext e)
{
RawLook = e.ReadValue<Vector2>();
}
public void EnableMovement()
{
_moveAction?.Enable();
}
public void DisableMovement()
{
RawMovement = Vector2.zero;
_moveAction.Disable();
}
}
}