diff --git a/Assets/_DDD/_ScriptAssets/So/GoogleSheetSettingsSo.asset b/Assets/_DDD/_ScriptAssets/So/GoogleSheetSettingsSo.asset index ed15a280d..ce84faadb 100644 --- a/Assets/_DDD/_ScriptAssets/So/GoogleSheetSettingsSo.asset +++ b/Assets/_DDD/_ScriptAssets/So/GoogleSheetSettingsSo.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ff1e408a4a99a64b29be143c156ef20f0a86e5d7567c67a47163b4c060926ffe -size 1237 +oid sha256:74585e5b87be57cfa66648eb020cb0198d76208cb5901d4f77bef9854d4e0eff +size 1251 diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CookwareData.cs b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CookwareData.cs index 73d3cb657..f7aceaaf8 100644 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CookwareData.cs +++ b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/CookwareData.cs @@ -4,6 +4,19 @@ namespace DDD { + public enum CookwareType + { + None = 0, + Pot = 1, + Fryer = 2, + FirePit = 3, + CuttingBoard = 4, + Griddle = 5, + MagicOven = 6, + JuiceMachine = 7, + Barrel = 8, + } + [Serializable] public class CookwareData : IId { diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/EnvironmentData.cs b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/EnvironmentData.cs index 2169d3349..7bcae5499 100644 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/EnvironmentData.cs +++ b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/EnvironmentData.cs @@ -4,6 +4,13 @@ namespace DDD { + public enum RendererType + { + None = 0, + Sprite = 1, + Spine = 2, + } + [Serializable] public class EnvironmentData : IId { diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/ItemData.cs b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/ItemData.cs index 3419b30c9..d4b5ba409 100644 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/ItemData.cs +++ b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/ItemData.cs @@ -4,6 +4,16 @@ namespace DDD { + public enum ItemType + { + None = 0, + Food = 1, + Ingredient = 2, + Environment = 3, + Drink = 4, + Recipe = 5, + } + [Serializable] public class ItemData : IId { diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/RecipeData.cs b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/RecipeData.cs index 714e8f98a..a38afbd14 100644 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/RecipeData.cs +++ b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/Classes/RecipeData.cs @@ -4,6 +4,13 @@ namespace DDD { + public enum RecipeType + { + None = 0, + FoodRecipe = 1, + DrinkRecipe = 2, + } + [Serializable] public class RecipeData : IId { diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/EnumTypes.cs b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/EnumTypes.cs index 49ff66363..7935df725 100644 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/EnumTypes.cs +++ b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/EnumTypes.cs @@ -3,41 +3,4 @@ namespace DDD { - public enum CookwareType - { - None = 0, - Barrel = 1, - CuttingBoard = 2, - FirePit = 3, - Fryer = 4, - Griddle = 5, - JuiceMachine = 6, - MagicOven = 7, - Pot = 8, - } - - public enum ItemType - { - None = 0, - Drink = 1, - Environment = 2, - Food = 3, - Ingredient = 4, - Recipe = 5, - } - - public enum RecipeType - { - None = 0, - DrinkRecipe = 1, - FoodRecipe = 2, - } - - public enum RendererType - { - None = 0, - Spine = 1, - Sprite = 2, - } - } diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/GoogleSheetJson.json b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/GoogleSheetJson.json index cebc1d0bd..946bb0616 100644 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/GoogleSheetJson.json +++ b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/GoogleSheetJson.json @@ -99,7 +99,7 @@ "CustomerLimitCount": 3, "Customers:string": "customer_001", "Test": "", - "Tests": "435, 25" + "Tests": 435 }, { "Id:string": "customer_pool_006", @@ -198,7 +198,7 @@ "Customers6": "", "Test": "", "Tests1": 435, - "Tests2": 25, + "Tests2": "", "Tests3": "" }, { diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/So/LevelDataSo.asset b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/So/LevelDataSo.asset deleted file mode 100644 index 7b7eb2a3c..000000000 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/So/LevelDataSo.asset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:633f15de93305e44d4275f65f010caa7cb77436a92ed3bdff21b976b196b456f -size 2093 diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/So/LevelDataSo.asset.meta b/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/So/LevelDataSo.asset.meta deleted file mode 100644 index b7c52a31c..000000000 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/So/LevelDataSo.asset.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3392661ff91138a4991ec360e86907cb -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 11400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/Core/Implementations/Reload/SessionStateReloadCoordinator.cs b/Assets/_DDD/_Scripts/GenerateGoogleSheet/Core/Implementations/Reload/SessionStateReloadCoordinator.cs index 3d90f9ac9..747fc1659 100644 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/Core/Implementations/Reload/SessionStateReloadCoordinator.cs +++ b/Assets/_DDD/_Scripts/GenerateGoogleSheet/Core/Implementations/Reload/SessionStateReloadCoordinator.cs @@ -80,7 +80,7 @@ private static async void TryRun() { // 짧은 안정화 대기 (도메인 리로드 직후 임포트 마무리용) await Task.Delay(100); - await manager.ContinueSoSyncAfterReload_Public(); // ← 아래 3) 참고(퍼블릭 메서드) + await manager.ContinueSoSyncAfterReload(); // ← 아래 3) 참고(퍼블릭 메서드) } catch (System.Exception e) { diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/Core/Manager/GoogleSheetManager.cs b/Assets/_DDD/_Scripts/GenerateGoogleSheet/Core/Manager/GoogleSheetManager.cs index 5846c5da7..fa18c6360 100644 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/Core/Manager/GoogleSheetManager.cs +++ b/Assets/_DDD/_Scripts/GenerateGoogleSheet/Core/Manager/GoogleSheetManager.cs @@ -24,6 +24,7 @@ public class GoogleSheetManager : ScriptableObject [SerializeField] private int _selectedVersionIndex; private string _lastJsonCache; + private bool _isBusy; private IGoogleSheetSource _source; private IJsonDiffer _differ; @@ -129,21 +130,22 @@ await RunOnMainThread(() => } // 6) SO 동기화 - await ContinueSoSync(json); + await ContinueSoSync(json, true); } - public async Task ContinueSoSyncAfterReload_Public() + public async Task ContinueSoSyncAfterReload() { if (string.IsNullOrEmpty(_lastJsonCache)) { Debug.LogWarning("[GoogleSheetManager] 리로드 후 캐시 JSON 없음"); return; } - await ContinueSoSync(_lastJsonCache); + await ContinueSoSync(_lastJsonCache, true); _lastJsonCache = null; } - private async Task ContinueSoSync(string json) + // 기존 메서드 대체 + private async Task ContinueSoSync(string json, bool saveSnapshot) { var selected = new HashSet(StringComparer.Ordinal); if (_settings.AutoCreateSheets != null) foreach (var s in _settings.AutoCreateSheets) selected.Add(s); @@ -159,13 +161,17 @@ private async Task ContinueSoSync(string json) _addressablesRegistrar.BuildIfNeeded(_settings.AutoBuildAddressables); } - _versionStore.SaveSnapshot(json, _editorName, _settings.BackupsFolderAssetPath); - _editorName = null; + if (saveSnapshot) + { + _versionStore.SaveSnapshot(json, _editorName, _settings.BackupsFolderAssetPath); + _editorName = null; + } Debug.Log(ok ? "✅ SO 동기화 완료" : "⚠️ SO 동기화 중 일부 실패"); await Task.CompletedTask; } + [Button("선택 버전으로 복구")] public async Task RestoreWithVersionIndex() { @@ -208,7 +214,7 @@ public async Task RestoreWithVersionIndex() return; } - await ContinueSoSync(restoreJson); + await ContinueSoSync(restoreJson, true); } [Button("선택 버전과 현재 비교")] @@ -299,6 +305,122 @@ private int GetSnapshotCountSafe() var log = AssetDatabase.LoadAssetAtPath(_settings.ChangeLogAssetPath); return (log != null && log.Logs != null) ? log.Logs.Count : 0; } + + private async Task GuardAsync(Func body, string tag) + { + if (_isBusy) + { + Debug.LogWarning($"[{tag}] 이미 실행 중입니다."); + return false; + } + + _isBusy = true; + try + { + await body(); + return true; + } + catch (Exception e) + { + Debug.LogError($"[{tag}] 실행 중 예외: {e}"); + return false; + } + finally + { + _isBusy = false; + } + } + + [Button("데이터만 가져오기 (웹앱/로컬 소스)")] + public async Task FetchJsonOnly() + { + await GuardAsync(async () => + { + if (_settings == null) { Debug.LogError("Settings So가 없습니다."); return; } + BuildServices(); + + Debug.Log("[FetchJsonOnly] 시작"); + var json = await _source.FetchAllJsonAsync(); + if (string.IsNullOrWhiteSpace(json)) + { + Debug.LogWarning("[FetchJsonOnly] 가져온 JSON이 비어있습니다."); + return; + } + + await RunOnMainThread(() => + { + var full = GoogleSheetSettingsSo.AssetToFull(_settings.JsonWorkFileAssetPath); + var dir = System.IO.Path.GetDirectoryName(full); + if (!string.IsNullOrEmpty(dir) && !System.IO.Directory.Exists(dir)) + System.IO.Directory.CreateDirectory(dir); + + System.IO.File.WriteAllText(full, json); + AssetDatabase.ImportAsset(_settings.JsonWorkFileAssetPath); + }); + + Debug.Log("[FetchJsonOnly] 완료"); + }, tag: "FetchJsonOnly"); + } + + + [Button("코드만 생성 (현재 JSON)")] + public async Task GenerateCodeOnlyFromCurrentJson() + { + if (_settings == null) { Debug.LogError("Settings So가 없습니다."); return; } + BuildServices(); + + var text = AssetDatabase.LoadAssetAtPath(_settings.JsonWorkFileAssetPath); + if (text == null) + { + EditorUtility.DisplayDialog( + "코드 생성 불가", + $"작업 JSON이 없습니다.\n{_settings.JsonWorkFileAssetPath}\n먼저 데이터 가져오기를 실행하세요.", + "확인"); + return; + } + + var gen = _codeGenerator.Generate( + text.text, + _settings.AutoCreateSheets ?? new List(), + _settings.RootNamespace, + _settings.GenerateAssetBasePath, + _settings.EnumTypesAssetPath, + _settings.ClassesFolderAssetPath + ); + + if (gen.AnyFileCreated) + { + // 코드만 생성: 리로드만 기다리고 종료 (SoSync 예약 X) + while (EditorApplication.isCompiling) await Task.Delay(150); + AssetDatabase.Refresh(); + Debug.Log("✅ 코드만 생성 완료 (리로드됨)."); + } + else + { + Debug.Log("코드 생성: 변경 없음."); + } + } + + [Button("SO만 동기화 (현재 JSON)")] + public async Task SyncSoOnlyFromCurrentJson() + { + if (_settings == null) { Debug.LogError("Settings So가 없습니다."); return; } + BuildServices(); + + var text = AssetDatabase.LoadAssetAtPath(_settings.JsonWorkFileAssetPath); + if (text == null) + { + EditorUtility.DisplayDialog( + "SO 동기화 불가", + $"작업 JSON이 없습니다.\n{_settings.JsonWorkFileAssetPath}\n먼저 데이터 가져오기 또는 코드 생성 파이프라인을 실행하세요.", + "확인"); + return; + } + + // 스냅샷 남기지 않음(필요하면 true로 바꾸세요) + await ContinueSoSync(text.text, saveSnapshot: false); + Debug.Log("✅ SO만 동기화 완료."); + } } } #endif \ No newline at end of file