카메라 등록 방식 변경
This commit is contained in:
parent
ac3f1a4b9b
commit
5e23e96af5
@ -15,6 +15,17 @@ private void Awake()
|
|||||||
_cinemachineCamera = GetComponent<CinemachineCamera>();
|
_cinemachineCamera = GetComponent<CinemachineCamera>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
CameraManager.Instance.RegisterCamera(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
var cameraManager = CameraManager.Instance;
|
||||||
|
cameraManager?.UnRegisterCamera(this);
|
||||||
|
}
|
||||||
|
|
||||||
public int GetPriority() => _cinemachineCamera.Priority;
|
public int GetPriority() => _cinemachineCamera.Priority;
|
||||||
public void SetPriority(int newPriority) => _cinemachineCamera.Priority = newPriority;
|
public void SetPriority(int newPriority) => _cinemachineCamera.Priority = newPriority;
|
||||||
public void SetFollowTarget(Transform target) => _cinemachineCamera.Follow = target;
|
public void SetFollowTarget(Transform target) => _cinemachineCamera.Follow = target;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
using Unity.Cinemachine;
|
using Unity.Cinemachine;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace DDD
|
namespace DDD
|
||||||
{
|
{
|
||||||
@ -44,12 +43,7 @@ public Task Init()
|
|||||||
|
|
||||||
public void PostInit()
|
public void PostInit()
|
||||||
{
|
{
|
||||||
var cameraGameObjects = FindObjectsByType<CameraGameObject>(FindObjectsInactive.Include, FindObjectsSortMode.None);
|
|
||||||
foreach (var cameraGameObject in cameraGameObjects)
|
|
||||||
{
|
|
||||||
RegisterCamera(cameraGameObject);
|
|
||||||
}
|
|
||||||
_initializationTask.SetResult(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterCamera(CameraGameObject cameraGameObject)
|
public void RegisterCamera(CameraGameObject cameraGameObject)
|
||||||
@ -72,16 +66,9 @@ public void SwitchCamera(CameraType cameraType, CinemachineBlendDefinition.Style
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<CameraGameObject> GetCameraGameObject(CameraType cameraType)
|
public CameraGameObject GetCameraGameObject(CameraType cameraType)
|
||||||
{
|
{
|
||||||
await _initializationTask.Task;
|
return _cameraGameObjects.GetValueOrDefault(cameraType);
|
||||||
|
|
||||||
if (_cameraGameObjects.TryGetValue(cameraType, out var cameraGameObject))
|
|
||||||
{
|
|
||||||
return cameraGameObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,22 +1,20 @@
|
|||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace DDD
|
namespace DDD
|
||||||
{
|
{
|
||||||
public class RestaurantPlayerCharacter : RestaurantCharacter
|
public class RestaurantPlayerCharacter : RestaurantCharacter
|
||||||
{
|
{
|
||||||
protected override void Awake()
|
protected override async void Awake()
|
||||||
{
|
{
|
||||||
base.Awake();
|
base.Awake();
|
||||||
|
|
||||||
_ = Initialize();
|
PlayerManager.Instance.RegisterPlayer(gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Initialize()
|
protected override void Start()
|
||||||
{
|
{
|
||||||
PlayerManager.Instance.RegisterPlayer(gameObject);
|
base.Start();
|
||||||
var cameraObject = await CameraManager.Instance.GetCameraGameObject(CameraType.RestaurantBaseCamera);
|
|
||||||
cameraObject?.SetFollowAndLookAtTarget(transform);
|
var cameraObject = CameraManager.Instance.GetCameraGameObject(CameraType.RestaurantBaseCamera);
|
||||||
|
cameraObject.SetFollowAndLookAtTarget(transform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user