Files
Colosseum/Assets/External/Animations/AnimationBaseLocomotion/Samples/Scripts/InputSystem/InputReader.cs
dal4segno c265f980db chore: Assets 디렉토리 구조 정리 및 네이밍 컨벤션 적용
- Assets/_Game/ 하위로 게임 에셋 통합
- External/ 패키지 벤더별 분류 (Synty, Animations, UI)
- 에셋 네이밍 컨벤션 확립 및 적용
  (Data_Skill_, Data_SkillEffect_, Prefab_, Anim_, Model_, BT_ 등)
- pre-commit hook으로 네이밍 컨벤션 자동 검사 추가
- RESTRUCTURE_CHECKLIST.md 작성

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-16 19:08:27 +09:00

170 lines
5.0 KiB
C#

// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
//
// Use of this software is subject to the terms and conditions of the Synty Studios End User Licence Agreement (EULA)
// available at: https://syntystore.com/pages/end-user-licence-agreement
//
// Sample scripts are included only as examples and are not intended as production-ready.
using System;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Serialization;
namespace Synty.AnimationBaseLocomotion.Samples.InputSystem
{
public class InputReader : MonoBehaviour, Controls.IPlayerActions
{
public Vector2 _mouseDelta;
public Vector2 _moveComposite;
public float _movementInputDuration;
public bool _movementInputDetected;
private Controls _controls;
public Action onAimActivated;
public Action onAimDeactivated;
public Action onCrouchActivated;
public Action onCrouchDeactivated;
public Action onJumpPerformed;
public Action onLockOnToggled;
public Action onSprintActivated;
public Action onSprintDeactivated;
public Action onWalkToggled;
/// <inheritdoc cref="OnEnable" />
private void OnEnable()
{
if (_controls == null)
{
_controls = new Controls();
_controls.Player.SetCallbacks(this);
}
_controls.Player.Enable();
}
/// <inheritdoc cref="OnDisable" />
public void OnDisable()
{
_controls.Player.Disable();
}
/// <summary>
/// Defines the action to perform when the OnLook callback is called.
/// </summary>
/// <param name="context">The context of the callback.</param>
public void OnLook(InputAction.CallbackContext context)
{
_mouseDelta = context.ReadValue<Vector2>();
}
/// <summary>
/// Defines the action to perform when the OnMove callback is called.
/// </summary>
/// <param name="context">The context of the callback.</param>
public void OnMove(InputAction.CallbackContext context)
{
_moveComposite = context.ReadValue<Vector2>();
_movementInputDetected = _moveComposite.magnitude > 0;
}
/// <summary>
/// Defines the action to perform when the OnJump callback is called.
/// </summary>
/// <param name="context">The context of the callback.</param>
public void OnJump(InputAction.CallbackContext context)
{
if (!context.performed)
{
return;
}
onJumpPerformed?.Invoke();
}
/// <summary>
/// Defines the action to perform when the OnToggleWalk callback is called.
/// </summary>
/// <param name="context">The context of the callback.</param>
public void OnToggleWalk(InputAction.CallbackContext context)
{
if (!context.performed)
{
return;
}
onWalkToggled?.Invoke();
}
/// <summary>
/// Defines the action to perform when the OnSprint callback is called.
/// </summary>
/// <param name="context">The context of the callback.</param>
public void OnSprint(InputAction.CallbackContext context)
{
if (context.started)
{
onSprintActivated?.Invoke();
}
else if (context.canceled)
{
onSprintDeactivated?.Invoke();
}
}
/// <summary>
/// Defines the action to perform when the OnCrouch callback is called.
/// </summary>
/// <param name="context">The context of the callback.</param>
public void OnCrouch(InputAction.CallbackContext context)
{
if (context.started)
{
onCrouchActivated?.Invoke();
}
else if (context.canceled)
{
onCrouchDeactivated?.Invoke();
}
}
/// <summary>
/// Defines the action to perform when the OnAim callback is called.
/// </summary>
/// <param name="context">The context of the callback.</param>
public void OnAim(InputAction.CallbackContext context)
{
if (context.started)
{
onAimActivated?.Invoke();
}
if (context.canceled)
{
onAimDeactivated?.Invoke();
}
}
/// <summary>
/// Defines the action to perform when the OnLockOn callback is called.
/// </summary>
/// <param name="context">The context of the callback.</param>
public void OnLockOn(InputAction.CallbackContext context)
{
if (!context.performed)
{
return;
}
onLockOnToggled?.Invoke();
onSprintDeactivated?.Invoke();
}
}
}