DDD-29, 30 카메라 컴포넌트 추가 및 카메라 매니저 구현

This commit is contained in:
NTG_Lenovo 2025-07-10 20:06:51 +09:00
parent b83e4c3a5e
commit 3d5090d905
9 changed files with 77 additions and 112 deletions

View File

@ -4889,63 +4889,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 04cb72fe661fd534b950283199ac4a83, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1922601885
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 3914215459674519121, guid: 9f16b0b665c13444aaced76f8dfe3136, type: 3}
propertyPath: m_Name
value: GameManager
objectReference: {fileID: 0}
- target: {fileID: 7699237936705830620, guid: 9f16b0b665c13444aaced76f8dfe3136, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7699237936705830620, guid: 9f16b0b665c13444aaced76f8dfe3136, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7699237936705830620, guid: 9f16b0b665c13444aaced76f8dfe3136, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7699237936705830620, guid: 9f16b0b665c13444aaced76f8dfe3136, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7699237936705830620, guid: 9f16b0b665c13444aaced76f8dfe3136, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7699237936705830620, guid: 9f16b0b665c13444aaced76f8dfe3136, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7699237936705830620, guid: 9f16b0b665c13444aaced76f8dfe3136, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 7699237936705830620, guid: 9f16b0b665c13444aaced76f8dfe3136, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7699237936705830620, guid: 9f16b0b665c13444aaced76f8dfe3136, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7699237936705830620, guid: 9f16b0b665c13444aaced76f8dfe3136, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 9f16b0b665c13444aaced76f8dfe3136, type: 3}
--- !u!114 &1926192729
MonoBehaviour:
m_ObjectHideFlags: 0
@ -32569,9 +32512,9 @@ GameObject:
- component: {fileID: 5019153103791118558}
- component: {fileID: 3688312069522590479}
- component: {fileID: 6463147863076644390}
- component: {fileID: 3956599978295396428}
- component: {fileID: 6463147863076644391}
m_Layer: 0
m_Name: BaseCam
m_Name: RestaurantBaseCamera
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -40437,20 +40380,6 @@ Transform:
- {fileID: 4542424994289489336}
m_Father: {fileID: 7160408128829955619}
m_LocalEulerAnglesHint: {x: 40, y: 0, z: 0}
--- !u!114 &3956599978295396428
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3015334612608266903}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4d75924d76b05344aa410607bc57db98, type: 3}
m_Name:
m_EditorClassIdentifier:
BoundingVolume: {fileID: 0}
SlowingDistance: 0
--- !u!4 &3964656713841077124
Transform:
m_ObjectHideFlags: 0
@ -62175,6 +62104,19 @@ MonoBehaviour:
DissipationDistance: 100
PropagationSpeed: 343
DefaultVelocity: {x: 0, y: -1, z: 0}
--- !u!114 &6463147863076644391
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3015334612608266903}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1b1ef0319328bf84a98bed912be4c61d, type: 3}
m_Name:
m_EditorClassIdentifier:
<Id>k__BackingField: RestaurantBaseCamera
--- !u!108 &6464483386687510218
Light:
m_ObjectHideFlags: 0
@ -85997,7 +85939,6 @@ SceneRoots:
m_Roots:
- {fileID: 1041959416}
- {fileID: 45031421}
- {fileID: 1922601885}
- {fileID: 1972254857}
- {fileID: 1804444097}
- {fileID: 5280945432206803416}

View File

@ -0,0 +1,31 @@
using Unity.Cinemachine;
using UnityEngine;
namespace DDD
{
public class CameraGameObject : MonoBehaviour
{
[field: SerializeField]
public string Id { get; private set; }
private CinemachineCamera _cinemachineCamera;
private void Awake()
{
_cinemachineCamera = GetComponent<CinemachineCamera>();
}
private void Start()
{
CameraManager.Instance.RegisterCamera(this);
}
private void OnDestroy()
{
CameraManager.Instance.UnRegisterCamera(this);
}
public int GetPriority() => _cinemachineCamera.Priority;
public void SetPriority(int newPriority) => _cinemachineCamera.Priority = newPriority;
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1b1ef0319328bf84a98bed912be4c61d

View File

@ -1,61 +1,44 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Sirenix.OdinInspector;
using Unity.Cinemachine;
using UnityEngine;
namespace DDD
{
public enum CameraType
{
BaseCam = 0,
}
public class CameraManager : Singleton<CameraManager>
public class CameraManager : Singleton<CameraManager>, IManager
{
[ShowInInspector, ReadOnly]
private Dictionary<CameraType, CinemachineCamera> _cameraDict;
private Dictionary<string, CameraGameObject> _cameraGameObjects;
private CinemachineBrain _cinemachineBrain;
protected override void OnAwake()
public void Init()
{
base.OnAwake();
_cameraGameObjects = new Dictionary<string, CameraGameObject>();
_cinemachineBrain = GetComponent<CinemachineBrain>();
}
public void ChangeScene(SceneType sceneType)
public void PostInit()
{
var foundCams = FindObjectsByType<CinemachineCamera>(FindObjectsInactive.Include, FindObjectsSortMode.None);
_cameraDict = new Dictionary<CameraType, CinemachineCamera>(foundCams.Length);
}
foreach (var cam in foundCams)
{
if (Enum.TryParse<CameraType>(cam.name, out var type))
{
if (!_cameraDict.TryAdd(type, cam))
Debug.LogWarning($"중복된 CameraType: {type}");
}
else
{
Debug.LogWarning($"Enum에 없는 카메라 이름: {cam.name}");
}
}
public void RegisterCamera(CameraGameObject cameraGameObject)
{
_cameraGameObjects.TryAdd(cameraGameObject.Id, cameraGameObject);
}
if (sceneType == SceneType.Restaurant)
{
SwitchCamera(CameraType.BaseCam);
}
public void UnRegisterCamera(CameraGameObject cameraGameObject)
{
_cameraGameObjects.Remove(cameraGameObject.Id);
}
public void SwitchCamera(CameraType cameraType, CinemachineBlendDefinition.Styles blendStyle = CinemachineBlendDefinition.Styles.Cut, float blendDuration = 1f)
public void SwitchCamera(CameraGameObject cameraGameObject, CinemachineBlendDefinition.Styles blendStyle = CinemachineBlendDefinition.Styles.Cut, float blendDuration = 1f)
{
_cinemachineBrain.DefaultBlend = new CinemachineBlendDefinition(blendStyle, blendDuration);
foreach (var pair in _cameraDict)
foreach (var item in _cameraGameObjects)
{
pair.Value.Priority = (pair.Key == cameraType) ? 10 : 0;
int newPriority = item.Value.Id == cameraGameObject.Id ? 10 : 0;
item.Value.SetPriority(newPriority);
}
}
}

View File

@ -45,8 +45,8 @@ Camera:
m_GameObject: {fileID: 7292682221138498026}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_ClearFlags: 2
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b3f6eaeb89086ab49a743c6cb3f4ddd2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: