Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e50adbf

Browse files
committed
feat: live2d 매니저 수정
1 parent a5c5456 commit e50adbf

File tree

5 files changed

+157
-3
lines changed

5 files changed

+157
-3
lines changed

‎Assets/App/Scenes/Live2d Sence.unity‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Transform:
157157
m_GameObject: {fileID: 194973787}
158158
serializedVersion: 2
159159
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
160-
m_LocalPosition: {x: 0.08988479, y: -0.3071759, z: 0.044769116}
160+
m_LocalPosition: {x: 0, y: 0, z: 0}
161161
m_LocalScale: {x: 1, y: 1, z: 1}
162162
m_ConstrainProportionsScale: 0
163163
m_Children: []
@@ -701,6 +701,7 @@ GameObject:
701701
- component: {fileID: 1916112490}
702702
- component: {fileID: 1916112492}
703703
- component: {fileID: 1916112491}
704+
- component: {fileID: 1916112493}
704705
m_Layer: 0
705706
m_Name: Live2D Manager
706707
m_TagString: Untagged
@@ -750,6 +751,24 @@ MonoBehaviour:
750751
m_EditorClassIdentifier:
751752
_modelRoot: {fileID: 1607417703}
752753
_modelRegistry: {fileID: 11400000, guid: cf68d9632ab0d2c42a02de12beecadff, type: 2}
754+
--- !u!114 &1916112493
755+
MonoBehaviour:
756+
m_ObjectHideFlags: 0
757+
m_CorrespondingSourceObject: {fileID: 0}
758+
m_PrefabInstance: {fileID: 0}
759+
m_PrefabAsset: {fileID: 0}
760+
m_GameObject: {fileID: 1916112489}
761+
m_Enabled: 1
762+
m_EditorHideFlags: 0
763+
m_Script: {fileID: 11500000, guid: c31e1b9082df088489ede1181874cde4, type: 3}
764+
m_Name:
765+
m_EditorClassIdentifier:
766+
_initializationManager: {fileID: 0}
767+
_managerRegistry: {fileID: 0}
768+
_dependencyManager: {fileID: 0}
769+
_autoInitializeOnStart: 1
770+
_createManagersIfNotExist: 1
771+
_camera: {fileID: 0}
753772
--- !u!1 &2028963604
754773
GameObject:
755774
m_ObjectHideFlags: 0

‎Assets/Core/Input/ScreenTapManager.cs‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,38 @@ public class ScreenTapManager : Singleton<ScreenTapManager>
102102

103103
public void Initialize(Camera cam)
104104
{
105-
if (_camera == null)
106-
_camera = cam;
105+
_camera = cam; // 항상 업데이트
107106
if(_inputProvider == null)
108107
_inputProvider = new DefaultInputProvider();
109108
if (_inputUpProvider == null)
110109
_inputUpProvider = new DefaultInputUpProvider();
111110
}
112111

112+
/// <summary>
113+
/// 씬 전환 시 Camera를 업데이트한다.
114+
/// </summary>
115+
public void UpdateCamera(Camera newCamera)
116+
{
117+
_camera = newCamera;
118+
Debug.Log($"[ScreenTapManager] Camera 업데이트: {(newCamera != null ? newCamera.name : "null")}");
119+
}
120+
121+
/// <summary>
122+
/// 현재 Main Camera로 Camera를 업데이트한다.
123+
/// </summary>
124+
public void UpdateToMainCamera()
125+
{
126+
var mainCamera = Camera.main;
127+
if (mainCamera != null)
128+
{
129+
UpdateCamera(mainCamera);
130+
}
131+
else
132+
{
133+
Debug.LogWarning("[ScreenTapManager] Main Camera를 찾을 수 없습니다.");
134+
}
135+
}
136+
113137
#region LockAt
114138
public bool TryGetLookDirection(out Vector3 lookDir)
115139
{

‎Assets/Core/Managers/SystemManager.cs‎

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ public class SystemManager : Singleton<SystemManager>
1818
[Header("Settings")]
1919
[SerializeField] private bool _autoInitializeOnStart = true;
2020
[SerializeField] private bool _createManagersIfNotExist = true;
21+
[SerializeField] private bool _autoUpdateCameraOnSceneChange = true;
22+
23+
[Header("Camera Settings")]
24+
[SerializeField] private Camera _camera;
2125

2226
private bool _initializationKickoffDone = false;
2327

@@ -52,15 +56,78 @@ protected override void Awake()
5256
InitializeGame();
5357
}
5458
}
59+
60+
private void Start()
61+
{
62+
// 씬 전환 이벤트 구독
63+
if (_autoUpdateCameraOnSceneChange)
64+
{
65+
UnityEngine.SceneManagement.SceneManager.sceneLoaded += OnSceneLoaded;
66+
}
67+
}
5568

5669
private void OnDestroy()
5770
{
5871
if (this != Instance)
5972
{
6073
return;
6174
}
75+
76+
// 이벤트 구독 해제
77+
if (_autoUpdateCameraOnSceneChange)
78+
{
79+
UnityEngine.SceneManagement.SceneManager.sceneLoaded -= OnSceneLoaded;
80+
}
81+
6282
Shutdown();
6383
}
84+
85+
/// <summary>
86+
/// 씬이 로드될 때 호출된다.
87+
/// </summary>
88+
private void OnSceneLoaded(UnityEngine.SceneManagement.Scene scene, UnityEngine.SceneManagement.LoadSceneMode mode)
89+
{
90+
Debug.Log($"[SystemManager] 씬 로드됨: {scene.name}");
91+
UpdateCamera();
92+
}
93+
94+
/// <summary>
95+
/// 현재 씬의 Main Camera로 Camera를 업데이트한다.
96+
/// </summary>
97+
public void UpdateCamera()
98+
{
99+
var mainCamera = Camera.main;
100+
if (mainCamera != null)
101+
{
102+
_camera = mainCamera;
103+
Debug.Log($"[SystemManager] Camera 업데이트: {mainCamera.name}");
104+
105+
// ScreenTapManager에 Camera 주입
106+
if (ScreenTapManager.Instance != null)
107+
{
108+
ScreenTapManager.Instance.UpdateCamera(_camera);
109+
}
110+
}
111+
else
112+
{
113+
Debug.LogWarning("[SystemManager] Main Camera를 찾을 수 없습니다.");
114+
}
115+
}
116+
117+
/// <summary>
118+
/// 수동으로 Camera를 설정한다.
119+
/// </summary>
120+
public void SetCamera(Camera camera)
121+
{
122+
_camera = camera;
123+
Debug.Log($"[SystemManager] Camera 수동 설정: {(camera != null ? camera.name : "null")}");
124+
125+
// ScreenTapManager에 Camera 주입
126+
if (ScreenTapManager.Instance != null)
127+
{
128+
ScreenTapManager.Instance.UpdateCamera(_camera);
129+
}
130+
}
64131

65132
public async void InitializeGame()
66133
{
@@ -69,6 +136,14 @@ public async void InitializeGame()
69136
return;
70137
}
71138
_initializationKickoffDone = true;
139+
140+
// Camera 업데이트 및 ScreenTapManager 초기화
141+
UpdateCamera();
142+
if (_camera != null)
143+
{
144+
ScreenTapManager.Instance.Initialize(_camera);
145+
}
146+
72147
await InitializeGameAsync();
73148
}
74149

@@ -111,9 +186,30 @@ public void Shutdown()
111186
public void LogManagerStatus()
112187
{
113188
Debug.Log($"[SystemManager] Initialized: {IsInitialized}");
189+
Debug.Log($"[SystemManager] Current Camera: {(_camera != null ? _camera.name : "null")}");
114190
_managerRegistry?.LogManagerStatus();
115191
}
116192

193+
[ContextMenu("Update Camera")]
194+
public void UpdateCameraFromContextMenu()
195+
{
196+
UpdateCamera();
197+
}
198+
199+
[ContextMenu("Set Main Camera")]
200+
public void SetMainCameraFromContextMenu()
201+
{
202+
var mainCamera = Camera.main;
203+
if (mainCamera != null)
204+
{
205+
SetCamera(mainCamera);
206+
}
207+
else
208+
{
209+
Debug.LogWarning("[SystemManager] Main Camera를 찾을 수 없습니다.");
210+
}
211+
}
212+
117213
public async UniTask TransitionToMainSceneAsync()
118214
{
119215
try

‎Assets/Domain/Character/Script/Manager/Live2DModelManager.cs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ public class Live2DModelManager : Singleton<Live2DModelManager>
1616
private readonly Dictionary<string, GameObject> _characterIdToInstance = new Dictionary<string, GameObject>();
1717
private string _activeCharacterId;
1818

19+
private void Awake()
20+
{
21+
base.Awake();
22+
}
23+
1924
#region Public Methods
2025

2126
/// <summary>

‎Assets/Domain/Character/Script/Test/Live2DModelTest.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ public class Live2DModelTest : MonoBehaviour
2929
private void Start()
3030
{
3131
SetupUI();
32+
33+
// Live2DModelManager 초기화 확인
34+
if (Live2DModelManager.Instance != null)
35+
{
36+
UpdateStatus("Live2DModelManager 준비 완료");
37+
}
38+
else
39+
{
40+
UpdateStatus("Live2DModelManager 초기화 실패");
41+
}
3242
}
3343

3444
/// <summary>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /