2025-07-10 11:06:51 +00:00
|
|
|
using Unity.Cinemachine;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace DDD
|
|
|
|
{
|
|
|
|
public class CameraGameObject : MonoBehaviour
|
|
|
|
{
|
|
|
|
[field: SerializeField]
|
2025-07-14 04:32:36 +00:00
|
|
|
public CameraType CameraType { get; private set; }
|
2025-07-10 11:06:51 +00:00
|
|
|
|
|
|
|
private CinemachineCamera _cinemachineCamera;
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
_cinemachineCamera = GetComponent<CinemachineCamera>();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
CameraManager.Instance.RegisterCamera(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
{
|
2025-07-11 05:48:49 +00:00
|
|
|
if (CameraManager.Instance)
|
|
|
|
{
|
|
|
|
CameraManager.Instance.UnRegisterCamera(this);
|
|
|
|
}
|
2025-07-10 11:06:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int GetPriority() => _cinemachineCamera.Priority;
|
|
|
|
public void SetPriority(int newPriority) => _cinemachineCamera.Priority = newPriority;
|
2025-07-11 05:48:49 +00:00
|
|
|
public void SetFollowTarget(Transform target) => _cinemachineCamera.Follow = target;
|
|
|
|
public void SetLookAtTarget(Transform target) => _cinemachineCamera.LookAt = target;
|
|
|
|
public void SetFollowAndLookAtTarget(Transform target)
|
|
|
|
{
|
|
|
|
SetFollowTarget(target);
|
|
|
|
SetLookAtTarget(target);
|
|
|
|
}
|
2025-07-10 11:06:51 +00:00
|
|
|
}
|
|
|
|
}
|