From 3cf799e0399b5107076dd549b921f5ff548ce83a Mon Sep 17 00:00:00 2001 From: 99jamin <99jamin56@gmail.com> Date: Mon, 21 Apr 2025 16:24:47 +0900 Subject: [PATCH] =?UTF-8?q?Deg-23=20[Feat]=20=EC=84=B8=EC=9D=B4=EB=B8=8C?= =?UTF-8?q?=20=EB=A7=A4=EB=8B=88=EC=A0=80=20=EC=8B=B1=EA=B8=80=ED=86=A4=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/KJM/KJM.unity | 4 ++-- Assets/KJM/KJM_Test/SaveManager.cs | 15 +++++++++---- .../KJM_Test/{GM Test.cs => StatManager.cs} | 22 ++++++++++++++++--- .../{GM Test.cs.meta => StatManager.cs.meta} | 0 4 files changed, 32 insertions(+), 9 deletions(-) rename Assets/KJM/KJM_Test/{GM Test.cs => StatManager.cs} (81%) rename Assets/KJM/KJM_Test/{GM Test.cs.meta => StatManager.cs.meta} (100%) diff --git a/Assets/KJM/KJM.unity b/Assets/KJM/KJM.unity index e21fc881..0d91b2f4 100644 --- a/Assets/KJM/KJM.unity +++ b/Assets/KJM/KJM.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:54bf19d9e03c4f3d4258e6174b6a6a85cc02677928c70318c3e1421d5e8d0765 -size 40881 +oid sha256:7f13f719e71b8e944fc097d5a437f5e135e094a1cf536cc80881327f9a5dbe59 +size 48687 diff --git a/Assets/KJM/KJM_Test/SaveManager.cs b/Assets/KJM/KJM_Test/SaveManager.cs index 3ed99cce..f9eb89ab 100644 --- a/Assets/KJM/KJM_Test/SaveManager.cs +++ b/Assets/KJM/KJM_Test/SaveManager.cs @@ -3,8 +3,9 @@ using System.Collections.Generic; using System.IO; using CI.QuickSave; using UnityEngine; +using UnityEngine.SceneManagement; -public class SaveManager : MonoBehaviour +public class SaveManager : Singleton { private const string SaveFolder = "QuickSave"; private const string SaveFileName = "Save_Main.json"; @@ -12,6 +13,7 @@ public class SaveManager : MonoBehaviour private Save mainSave; private Save backupSave; + void Start() { @@ -33,7 +35,7 @@ public class SaveManager : MonoBehaviour public void Save() { - if(JsonUtility.ToJson(mainSave) == JsonUtility.ToJson(GMTest.instance.ToSaveData())) //같은 상태를 저장하면 저장되지 않음. 백업 덮어쓰기 방지 + if(JsonUtility.ToJson(mainSave) == JsonUtility.ToJson(StatManager.instance.ToSaveData())) //같은 상태는 저장되지 않음. 백업 덮어쓰기 방지. return; backupSave = LoadMain(); //메인 세이브를 백업 세이브에 로드 @@ -55,7 +57,7 @@ public class SaveManager : MonoBehaviour private void UpdateSaveInfo() { - mainSave = GMTest.instance.ToSaveData(); //스탯을 관리하는 클래스에 선언된 스탯 업데이트 함수를 호출 + mainSave = StatManager.instance.ToSaveData(); //스탯을 관리하는 클래스에 선언된 스탯 업데이트 함수를 호출 } private void SaveMain() @@ -83,5 +85,10 @@ public class SaveManager : MonoBehaviour return QuickSaveReader.Create("Save_Backup") .Read("Backup"); } - + + protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode) + { + Save(); + Debug.Log("자동저장"); + } } diff --git a/Assets/KJM/KJM_Test/GM Test.cs b/Assets/KJM/KJM_Test/StatManager.cs similarity index 81% rename from Assets/KJM/KJM_Test/GM Test.cs rename to Assets/KJM/KJM_Test/StatManager.cs index 10769d7d..ff9e0ad1 100644 --- a/Assets/KJM/KJM_Test/GM Test.cs +++ b/Assets/KJM/KJM_Test/StatManager.cs @@ -2,11 +2,15 @@ using System; using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.SceneManagement; using Random = UnityEngine.Random; -public class GMTest : MonoBehaviour +/// +/// 테스트용 임시 클래스 +/// +public class StatManager : MonoBehaviour { - public static GMTest instance; + public static StatManager instance; public int attackLevel; public int attackSpeedLevel; @@ -24,7 +28,10 @@ public class GMTest : MonoBehaviour { instance = this; } - + + /// + /// 스탯값 변화 + /// public void ChangeValue() { float floatValue = Random.Range(0f, 2f); @@ -49,6 +56,10 @@ public class GMTest : MonoBehaviour } + /// + /// 스탯값 반환 + /// + /// public Save ToSaveData() { return new Save @@ -71,4 +82,9 @@ public class GMTest : MonoBehaviour } }; } + + public void SceneChange() + { + SceneManager.LoadScene("Main"); + } } diff --git a/Assets/KJM/KJM_Test/GM Test.cs.meta b/Assets/KJM/KJM_Test/StatManager.cs.meta similarity index 100% rename from Assets/KJM/KJM_Test/GM Test.cs.meta rename to Assets/KJM/KJM_Test/StatManager.cs.meta