|
|
|
|
|
|
using System; |
|
|
|
using UnityEngine; |
|
|
|
using Cinemachine; |
|
|
|
using System.Collections; |
|
|
|
|
|
|
|
public class CameraManager : MonoBehaviour |
|
|
|
{ |
|
|
|
|
|
|
[Tooltip("The CameraManager listens to this event, fired by objects in any scene, to adapt camera position")] |
|
|
|
[SerializeField] private TransformEventChannelSO _frameObjectChannel = default; |
|
|
|
|
|
|
|
|
|
|
|
private bool cameraMovementLock = false; |
|
|
|
|
|
|
|
public void SetupProtagonistVirtualCamera(Transform target) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
Cursor.lockState = CursorLockMode.Locked; |
|
|
|
Cursor.visible = false; |
|
|
|
|
|
|
|
StartCoroutine(DisableMouseControlForFrame()); |
|
|
|
} |
|
|
|
|
|
|
|
IEnumerator DisableMouseControlForFrame() |
|
|
|
{ |
|
|
|
cameraMovementLock = true; |
|
|
|
yield return new WaitForEndOfFrame(); |
|
|
|
cameraMovementLock = false; |
|
|
|
} |
|
|
|
|
|
|
|
private void OnDisableMouseControlCamera() |
|
|
|
|
|
|
|
|
|
|
private void OnCameraMove(Vector2 cameraMovement, bool isDeviceMouse) |
|
|
|
{ |
|
|
|
if (cameraMovementLock) |
|
|
|
return; |
|
|
|
|
|
|
|
if (isDeviceMouse && !_isRMBPressed) |
|
|
|
return; |
|
|
|
|
|
|
|