2024-06-03 18:26:03 +00:00
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
using Unity.Cinemachine;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace BlueWater
|
|
|
|
{
|
|
|
|
public class CombatCameraManager : Singleton<CombatCameraManager>
|
|
|
|
{
|
|
|
|
// Components
|
|
|
|
#region Components
|
|
|
|
|
|
|
|
[Title("카메라")]
|
|
|
|
[SerializeField]
|
|
|
|
private Transform _cinemachineCameras;
|
|
|
|
|
|
|
|
[field: SerializeField]
|
|
|
|
public CinemachineCamera BaseCombatCamera { get; private set; }
|
|
|
|
|
2024-07-02 18:27:56 +00:00
|
|
|
public Camera MainCamera { get; private set; }
|
|
|
|
public Camera UiCamera { get; private set; }
|
2024-06-03 18:26:03 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
// Unity events
|
|
|
|
#region Unity events
|
|
|
|
|
|
|
|
protected override void OnAwake()
|
|
|
|
{
|
|
|
|
Initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
if (!GameManager.Instance) return;
|
|
|
|
|
2024-06-06 11:07:07 +00:00
|
|
|
GameManager.Instance.OnInstantiatePlayer += SetFollow;
|
2024-06-03 18:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
{
|
|
|
|
if (!GameManager.Instance) return;
|
|
|
|
|
2024-06-06 11:07:07 +00:00
|
|
|
GameManager.Instance.OnInstantiatePlayer -= SetFollow;
|
2024-06-03 18:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
// Initialize methods
|
|
|
|
#region Initialize methods
|
|
|
|
|
|
|
|
private void Initialize()
|
|
|
|
{
|
|
|
|
_cinemachineCameras = GameObject.Find("CinemachineCameras").transform;
|
|
|
|
BaseCombatCamera = _cinemachineCameras.Find("BaseCombatCamera").GetComponent<CinemachineCamera>();
|
|
|
|
|
|
|
|
BaseCombatCamera.Priority = 1;
|
|
|
|
|
2024-07-02 18:27:56 +00:00
|
|
|
MainCamera = GetComponent<Camera>();
|
|
|
|
UiCamera = MainCamera.transform.Find("UiCamera").GetComponent<Camera>();
|
2024-06-03 18:26:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
#region Methods
|
|
|
|
|
|
|
|
public void SetFollow(Transform target)
|
|
|
|
{
|
|
|
|
BaseCombatCamera.Follow = target;
|
|
|
|
}
|
|
|
|
|
|
|
|
// public void SetFollowAndLookAt(Transform target)
|
|
|
|
// {
|
|
|
|
// BaseCombatCamera.Follow = target;
|
|
|
|
// BaseCombatCamera.LookAt = target;
|
|
|
|
// }
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|