Skip to content

Commit

Permalink
Feat: Add DataCheater.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
wooyn730 committed Sep 27, 2024
1 parent 3fe890f commit 2862d7d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Assets/Resources/Cheat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Assets/Scripts/Runtime/Main/DataCheater.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Runtime.Manager;
using UnityEngine;

namespace Runtime.Main
Expand All @@ -6,6 +7,19 @@ namespace Runtime.ETC
{
public class DataCheater : MonoBehaviour
{
public void LoadCheatData(string file)
{
TextAsset jsonFile = Resources.Load<TextAsset>("Cheat/" + file); // (파일명).json 파일을 불러옴

if (jsonFile == null)
{
Debug.LogError("JSON file not found!");
}

string jsonData = jsonFile.text;
GameData data = JsonUtility.FromJson<GameData>(jsonData);
Managers.Data.ChangeData(data);
}
}
}
}
5 changes: 5 additions & 0 deletions Assets/Scripts/Runtime/Manager/DataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/build_info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Build from WOOS_COM at 2024-09-27 오후 10:57:12
Build from WOOS_COM at 2024-09-27 오후 11:08:07

0 comments on commit 2862d7d

Please sign in to comment.