구글 시트 기능 호출 분리

This commit is contained in:
NTG_Lenovo 2025-08-12 12:47:07 +09:00
parent 338d45d6cd
commit fad3ba39c8
11 changed files with 171 additions and 60 deletions

Binary file not shown.

View File

@ -4,6 +4,19 @@
namespace DDD namespace DDD
{ {
public enum CookwareType
{
None = 0,
Pot = 1,
Fryer = 2,
FirePit = 3,
CuttingBoard = 4,
Griddle = 5,
MagicOven = 6,
JuiceMachine = 7,
Barrel = 8,
}
[Serializable] [Serializable]
public class CookwareData : IId public class CookwareData : IId
{ {

View File

@ -4,6 +4,13 @@
namespace DDD namespace DDD
{ {
public enum RendererType
{
None = 0,
Sprite = 1,
Spine = 2,
}
[Serializable] [Serializable]
public class EnvironmentData : IId public class EnvironmentData : IId
{ {

View File

@ -4,6 +4,16 @@
namespace DDD namespace DDD
{ {
public enum ItemType
{
None = 0,
Food = 1,
Ingredient = 2,
Environment = 3,
Drink = 4,
Recipe = 5,
}
[Serializable] [Serializable]
public class ItemData : IId public class ItemData : IId
{ {

View File

@ -4,6 +4,13 @@
namespace DDD namespace DDD
{ {
public enum RecipeType
{
None = 0,
FoodRecipe = 1,
DrinkRecipe = 2,
}
[Serializable] [Serializable]
public class RecipeData : IId public class RecipeData : IId
{ {

View File

@ -3,41 +3,4 @@
namespace DDD 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,
}
} }

View File

@ -99,7 +99,7 @@
"CustomerLimitCount": 3, "CustomerLimitCount": 3,
"Customers:string": "customer_001", "Customers:string": "customer_001",
"Test": "", "Test": "",
"Tests": "435, 25" "Tests": 435
}, },
{ {
"Id:string": "customer_pool_006", "Id:string": "customer_pool_006",
@ -198,7 +198,7 @@
"Customers6": "", "Customers6": "",
"Test": "", "Test": "",
"Tests1": 435, "Tests1": 435,
"Tests2": 25, "Tests2": "",
"Tests3": "" "Tests3": ""
}, },
{ {

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 3392661ff91138a4991ec360e86907cb
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -80,7 +80,7 @@ private static async void TryRun()
{ {
// 짧은 안정화 대기 (도메인 리로드 직후 임포트 마무리용) // 짧은 안정화 대기 (도메인 리로드 직후 임포트 마무리용)
await Task.Delay(100); await Task.Delay(100);
await manager.ContinueSoSyncAfterReload_Public(); // ← 아래 3) 참고(퍼블릭 메서드) await manager.ContinueSoSyncAfterReload(); // ← 아래 3) 참고(퍼블릭 메서드)
} }
catch (System.Exception e) catch (System.Exception e)
{ {

View File

@ -24,6 +24,7 @@ public class GoogleSheetManager : ScriptableObject
[SerializeField] private int _selectedVersionIndex; [SerializeField] private int _selectedVersionIndex;
private string _lastJsonCache; private string _lastJsonCache;
private bool _isBusy;
private IGoogleSheetSource _source; private IGoogleSheetSource _source;
private IJsonDiffer _differ; private IJsonDiffer _differ;
@ -129,21 +130,22 @@ await RunOnMainThread(() =>
} }
// 6) SO 동기화 // 6) SO 동기화
await ContinueSoSync(json); await ContinueSoSync(json, true);
} }
public async Task ContinueSoSyncAfterReload_Public() public async Task ContinueSoSyncAfterReload()
{ {
if (string.IsNullOrEmpty(_lastJsonCache)) if (string.IsNullOrEmpty(_lastJsonCache))
{ {
Debug.LogWarning("[GoogleSheetManager] 리로드 후 캐시 JSON 없음"); Debug.LogWarning("[GoogleSheetManager] 리로드 후 캐시 JSON 없음");
return; return;
} }
await ContinueSoSync(_lastJsonCache); await ContinueSoSync(_lastJsonCache, true);
_lastJsonCache = null; _lastJsonCache = null;
} }
private async Task ContinueSoSync(string json) // 기존 메서드 대체
private async Task ContinueSoSync(string json, bool saveSnapshot)
{ {
var selected = new HashSet<string>(StringComparer.Ordinal); var selected = new HashSet<string>(StringComparer.Ordinal);
if (_settings.AutoCreateSheets != null) foreach (var s in _settings.AutoCreateSheets) selected.Add(s); 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); _addressablesRegistrar.BuildIfNeeded(_settings.AutoBuildAddressables);
} }
_versionStore.SaveSnapshot(json, _editorName, _settings.BackupsFolderAssetPath); if (saveSnapshot)
_editorName = null; {
_versionStore.SaveSnapshot(json, _editorName, _settings.BackupsFolderAssetPath);
_editorName = null;
}
Debug.Log(ok ? "✅ SO 동기화 완료" : "⚠️ SO 동기화 중 일부 실패"); Debug.Log(ok ? "✅ SO 동기화 완료" : "⚠️ SO 동기화 중 일부 실패");
await Task.CompletedTask; await Task.CompletedTask;
} }
[Button("선택 버전으로 복구")] [Button("선택 버전으로 복구")]
public async Task RestoreWithVersionIndex() public async Task RestoreWithVersionIndex()
{ {
@ -208,7 +214,7 @@ public async Task RestoreWithVersionIndex()
return; return;
} }
await ContinueSoSync(restoreJson); await ContinueSoSync(restoreJson, true);
} }
[Button("선택 버전과 현재 비교")] [Button("선택 버전과 현재 비교")]
@ -299,6 +305,122 @@ private int GetSnapshotCountSafe()
var log = AssetDatabase.LoadAssetAtPath<GoogleSheetChangeLog>(_settings.ChangeLogAssetPath); var log = AssetDatabase.LoadAssetAtPath<GoogleSheetChangeLog>(_settings.ChangeLogAssetPath);
return (log != null && log.Logs != null) ? log.Logs.Count : 0; return (log != null && log.Logs != null) ? log.Logs.Count : 0;
} }
private async Task<bool> GuardAsync(Func<Task> 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<TextAsset>(_settings.JsonWorkFileAssetPath);
if (text == null)
{
EditorUtility.DisplayDialog(
"코드 생성 불가",
$"작업 JSON이 없습니다.\n{_settings.JsonWorkFileAssetPath}\n먼저 데이터 가져오기를 실행하세요.",
"확인");
return;
}
var gen = _codeGenerator.Generate(
text.text,
_settings.AutoCreateSheets ?? new List<string>(),
_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<TextAsset>(_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 #endif