From 2862d7dd45c8d6cbefa70ca047876f2b2d2fd6c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9A=B0=EC=97=B0?= Date: Fri, 27 Sep 2024 23:09:32 +0900 Subject: [PATCH] Feat: Add DataCheater.cs --- Assets/Resources/Cheat.meta | 8 ++++++++ Assets/Scripts/Runtime/Main/DataCheater.cs | 14 ++++++++++++++ Assets/Scripts/Runtime/Manager/DataManager.cs | 5 +++++ Assets/StreamingAssets/build_info | 2 +- 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 Assets/Resources/Cheat.meta diff --git a/Assets/Resources/Cheat.meta b/Assets/Resources/Cheat.meta new file mode 100644 index 00000000..f1b6efd6 --- /dev/null +++ b/Assets/Resources/Cheat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 70d1894a1d27c7d4b90231fc6cc18235 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Runtime/Main/DataCheater.cs b/Assets/Scripts/Runtime/Main/DataCheater.cs index 7aa4da83..1cee707b 100644 --- a/Assets/Scripts/Runtime/Main/DataCheater.cs +++ b/Assets/Scripts/Runtime/Main/DataCheater.cs @@ -1,3 +1,4 @@ +using Runtime.Manager; using UnityEngine; namespace Runtime.Main @@ -6,6 +7,19 @@ namespace Runtime.ETC { public class DataCheater : MonoBehaviour { + public void LoadCheatData(string file) + { + TextAsset jsonFile = Resources.Load("Cheat/" + file); // (파일명).json 파일을 불러옴 + + if (jsonFile == null) + { + Debug.LogError("JSON file not found!"); + } + + string jsonData = jsonFile.text; + GameData data = JsonUtility.FromJson(jsonData); + Managers.Data.ChangeData(data); + } } } } \ No newline at end of file diff --git a/Assets/Scripts/Runtime/Manager/DataManager.cs b/Assets/Scripts/Runtime/Manager/DataManager.cs index 5e2d2b41..cd919d2a 100644 --- a/Assets/Scripts/Runtime/Manager/DataManager.cs +++ b/Assets/Scripts/Runtime/Manager/DataManager.cs @@ -185,6 +185,11 @@ public bool LoadGame() return true; } + public void ChangeData(GameData data) + { + Managers.Data.SaveData = data; + } + public void NewGame() { _gameData = new GameData { Version = Application.version }; diff --git a/Assets/StreamingAssets/build_info b/Assets/StreamingAssets/build_info index 59e0c848..1eee4efd 100644 --- a/Assets/StreamingAssets/build_info +++ b/Assets/StreamingAssets/build_info @@ -1 +1 @@ -Build from WOOS_COM at 2024-09-27 오후 10:57:12 \ No newline at end of file +Build from WOOS_COM at 2024-09-27 오후 11:08:07 \ No newline at end of file