36 lines
869 B
C#
36 lines
869 B
C#
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
using Unity.Cinemachine;
|
|
|
|
public class OrbitCameraMouseControl : MonoBehaviour
|
|
{
|
|
[Header("Input Actions")]
|
|
public InputActionReference aimAction; // CM Default / Aim
|
|
|
|
[Header("Cinemachine Components")]
|
|
public CinemachineInputAxisController inputAxisController;
|
|
|
|
private void OnEnable()
|
|
{
|
|
if (aimAction != null)
|
|
aimAction.action.Enable();
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
if (aimAction != null)
|
|
aimAction.action.Disable();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
bool isAiming = aimAction != null && aimAction.action.ReadValue<float>() > 0.5f;
|
|
|
|
if (inputAxisController != null)
|
|
{
|
|
inputAxisController.Controllers[0].Enabled = isAiming;
|
|
inputAxisController.Controllers[1].Enabled = isAiming;
|
|
}
|
|
}
|
|
}
|