From 0b201267bfc16e085dcc2313b358cd690e609f46 Mon Sep 17 00:00:00 2001 From: "aube.lee" Date: Sat, 1 Feb 2025 21:41:59 +0900 Subject: [PATCH] =?UTF-8?q?player=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=8B=B1=EA=B8=80=ED=86=A4=20=EA=B5=AC=EC=A1=B0=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/Common/PlayerDataManager.cs | 28 +++++++++++++++++++ .../Scripts/Common/PlayerDataManager.cs.meta | 11 ++++++++ .../Gameton/Scripts/UI/CharaterSelectUI.cs | 6 ++-- .../Assets/Gameton/Scripts/UI/TitleUI.cs | 4 +-- 4 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 Gameton-06/Assets/Gameton/Scripts/Common/PlayerDataManager.cs create mode 100644 Gameton-06/Assets/Gameton/Scripts/Common/PlayerDataManager.cs.meta diff --git a/Gameton-06/Assets/Gameton/Scripts/Common/PlayerDataManager.cs b/Gameton-06/Assets/Gameton/Scripts/Common/PlayerDataManager.cs new file mode 100644 index 00000000..86e5b11f --- /dev/null +++ b/Gameton-06/Assets/Gameton/Scripts/Common/PlayerDataManager.cs @@ -0,0 +1,28 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace TON +{ + public class PlayerDataManager : SingletonBase + { + // 사용자가 생성해둔 플레이어 데이터를 싱글톤으로 전역 사용하기 위함 + public List players { get; private set; } + + protected override void Awake() + { + base.Awake(); + LoadPlayerData(); + } + + private void LoadPlayerData() + { + players = JSONLoader.LoadFromResources>("Player"); + if (players == null) + { + players = new List(); + Debug.LogError("⚠️ Player data loading failed. Check if 'Player.json' exists in Resources folder."); + } + } + } +} diff --git a/Gameton-06/Assets/Gameton/Scripts/Common/PlayerDataManager.cs.meta b/Gameton-06/Assets/Gameton/Scripts/Common/PlayerDataManager.cs.meta new file mode 100644 index 00000000..0812bdca --- /dev/null +++ b/Gameton-06/Assets/Gameton/Scripts/Common/PlayerDataManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f52606f26bff734428ec67cdb89e0330 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Gameton-06/Assets/Gameton/Scripts/UI/CharaterSelectUI.cs b/Gameton-06/Assets/Gameton/Scripts/UI/CharaterSelectUI.cs index fc8a5e73..07888eea 100644 --- a/Gameton-06/Assets/Gameton/Scripts/UI/CharaterSelectUI.cs +++ b/Gameton-06/Assets/Gameton/Scripts/UI/CharaterSelectUI.cs @@ -23,6 +23,8 @@ namespace TON private void Start() { + playerDatas = PlayerDataManager.Singleton.players; + // 캐릭터를 선택한 이후에 버튼 활성화 할 수 있도록 초기 비활성화 적용 playButton.interactable = false; @@ -45,10 +47,6 @@ namespace TON } - public void SetPlayerDatas(List datas) - { - playerDatas = datas; - } public void SelectCharacter(int index) { diff --git a/Gameton-06/Assets/Gameton/Scripts/UI/TitleUI.cs b/Gameton-06/Assets/Gameton/Scripts/UI/TitleUI.cs index 5c42d9ee..52c07d3c 100644 --- a/Gameton-06/Assets/Gameton/Scripts/UI/TitleUI.cs +++ b/Gameton-06/Assets/Gameton/Scripts/UI/TitleUI.cs @@ -13,7 +13,8 @@ namespace TON // Main.Singleton?.ChangeScene(SceneType.Ingame); UIManager.Hide(UIList.TitleUI); - List players = JSONLoader.LoadFromResources>("Player"); + // 플레이어가 가지고 있는 캐릭터들의 데이터 불러옴 + List players = PlayerDataManager.Singleton.players; if (players == null) { @@ -23,7 +24,6 @@ namespace TON else { // 캐릭터가 있다면 내 캐릭터 목록에서 선택할 수 있도록 함 - charaterSelectUI.SetPlayerDatas(players); UIManager.Show(UIList.CharaterSelectUI); } }