diff --git a/Gameton-06/Assets/Gameton/Scripts/Common/JSONLoader.cs b/Gameton-06/Assets/Gameton/Scripts/Common/JSONLoader.cs
index 6c673452..271feb13 100644
--- a/Gameton-06/Assets/Gameton/Scripts/Common/JSONLoader.cs
+++ b/Gameton-06/Assets/Gameton/Scripts/Common/JSONLoader.cs
@@ -82,7 +82,6 @@ namespace TON
// 일반 객체는 그대로 JSON 변환
json = JsonUtility.ToJson(data, true);
}
- Debug.Log("SaveToFile ::: " + json);
File.WriteAllText(path, json);
Debug.Log($"파일 저장 성공 ::: {fileName}.json");
@@ -95,7 +94,7 @@ namespace TON
}
/// Resources.Load 로 읽어온 파일을 persistentDataPath 경로에 저장
- public static bool SaveJsonToPersistentData(string fileName)
+ public static void SaveJsonToPersistentData(string fileName)
{
if (fileName.EndsWith(".json"))
{
@@ -104,35 +103,36 @@ namespace TON
string persistentPath = GetPersistentPath(fileName);
+#if UNITY_ANDROID
// 📌 Step 1: persistentDataPath에 파일이 있는지 체크
+ // Android에서는 파일이 이미 존재하면 덮어쓰지 않도록 함
if (File.Exists(persistentPath))
{
Debug.Log($"⚠ {fileName}.json 파일이 이미 존재합니다. 덮어쓰지 않습니다. ({persistentPath})");
- return false;
}
-
+#endif
// 📌 Step 2: Resources에서 JSON 불러오기
- string path = "GameData/" + fileName; // Resources 폴더 내 경로
+ string path = DATA_PATH + fileName; // Resources 폴더 내 경로
TextAsset jsonFile = Resources.Load(path);
if (jsonFile != null)
{
File.WriteAllText(persistentPath, jsonFile.text);
Debug.Log($"✅ JSON 저장 완료 (처음 저장됨): {persistentPath}");
- return true;
}
else
{
- Debug.LogError($"❌ Resources에서 JSON 파일을 찾을 수 없음: {path}");
- return false;
+ Debug.LogError($"❌ Resources에서 JSON 파일을 찾을 s수 없음: {path}");
}
}
+
/// persistentDataPath 경로의 파일 읽어오기
public static T LoadJsonFromPersistentData(string fileName)
{
string path = GetPersistentPath(fileName);
+ Debug.Log($"LoadJsonFromPersistentData : {path}");
if (!File.Exists(path))
{
@@ -162,24 +162,37 @@ namespace TON
}
/// persistentDataPath 경로의 파일 데이터 업데이트
- public static void SaveUpdatedJsonToPersistentData(T updatedData, string fileName)
+ public static bool SaveUpdatedJsonToPersistentData(T updatedData, string fileName)
{
- string path = GetPersistentPath(fileName);
- string json;
-
- // 리스트인지 확인 후 JSON 변환
- if (typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition() == typeof(List<>))
+ try
{
- Wrapper wrapper = new Wrapper { items = updatedData };
- json = JsonUtility.ToJson(wrapper, true);
- }
- else
- {
- json = JsonUtility.ToJson(updatedData, true);
- }
+ string path = GetPersistentPath(fileName);
+ string json;
- File.WriteAllText(path, json);
- Debug.Log($"✅ JSON 데이터 업데이트 완료: {path}");
+ // 리스트인지 확인 후 JSON 변환
+ if (typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition() == typeof(List<>))
+ {
+ Wrapper wrapper = new Wrapper { items = updatedData };
+ json = JsonUtility.ToJson(wrapper, true);
+ }
+ else
+ {
+ json = JsonUtility.ToJson(updatedData, true);
+ }
+
+ Debug.Log($"SaveUpdatedJsonToPersistentData : {json}");
+
+ // 파일 저장
+ File.WriteAllText(path, json);
+ Debug.Log($"✅ JSON 데이터 업데이트 완료: {path}");
+
+ return true; // 저장 성공
+ }
+ catch (Exception ex)
+ {
+ Debug.LogError($"❌ JSON 저장 실패: {ex.Message}");
+ return false; // 저장 실패
+ }
}
diff --git a/Gameton-06/Assets/Gameton/Scripts/Skill/SkillDataManager.cs b/Gameton-06/Assets/Gameton/Scripts/Skill/SkillDataManager.cs
index 75b3a20f..aa22e7ea 100644
--- a/Gameton-06/Assets/Gameton/Scripts/Skill/SkillDataManager.cs
+++ b/Gameton-06/Assets/Gameton/Scripts/Skill/SkillDataManager.cs
@@ -35,7 +35,8 @@ namespace TON
skillDatas.Clear();
}
- skillDatas = JSONLoader.LoadFromResources>("skill");
+ JSONLoader.SaveJsonToPersistentData("skill");
+ skillDatas = JSONLoader.LoadJsonFromPersistentData>("skill");
if (skillDatas == null)
{
@@ -43,6 +44,24 @@ namespace TON
}
}
+ public void UpdateSkillData(string skillId, int slotNumber)
+ {
+ foreach (var skill in skillDatas)
+ {
+ if (skill.id == skillId)
+ {
+ skill.slotNumber = slotNumber;
+ }
+ if (skill.slotNumber == slotNumber && skill.id != skillId)
+ {
+ skill.slotNumber = 0;
+ }
+ }
+
+ Assert.IsTrue(JSONLoader.SaveUpdatedJsonToPersistentData(skillDatas, "skill"));
+ Initalize();
+ }
+
public void SetSkillInstances()
{
skillInstances = new SerializableDictionary();
@@ -159,21 +178,6 @@ namespace TON
return result;
}
- public void UpdateSkillData(string skillId, int slotNumber)
- {
- foreach (var skill in skillDatas)
- {
- if (skill.id == skillId)
- {
- skill.slotNumber = slotNumber;
- }
- if (skill.slotNumber == slotNumber && skill.id != skillId)
- {
- skill.slotNumber = 0;
- }
- }
- JSONLoader.SaveToFile(skillDatas, "skill");
- }
}
}
diff --git a/Gameton-06/Assets/Gameton/Scripts/UI/SkillSettingUI.cs b/Gameton-06/Assets/Gameton/Scripts/UI/SkillSettingUI.cs
index 0a7233be..cd9523fd 100644
--- a/Gameton-06/Assets/Gameton/Scripts/UI/SkillSettingUI.cs
+++ b/Gameton-06/Assets/Gameton/Scripts/UI/SkillSettingUI.cs
@@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic;
using UnityEditor.PackageManager;
using UnityEngine;
+using UnityEngine.Assertions;
using UnityEngine.EventSystems;
using UnityEngine.UI;
@@ -61,6 +62,7 @@ namespace TON
// 스킬 버튼을 생성
List activatedSkills = SkillDataManager.Singleton.GetEquippedSkills();
+ int maxEquipSkillCount = SkillDataManager.Singleton.GetActiveSkillCount();
for (int i = 0; i < 3; i++)
{
SkillSettingUI_SkillSlot newSkillSlot = Instantiate(skillSlotPrefab, skillSlotGroup);
@@ -72,8 +74,15 @@ namespace TON
}
else
{
- // 복제 됐을때 기본 상태가 잠금 상태
- newSkillSlot.GetComponent