구글 시트 기능 호출 분리
This commit is contained in:
parent
338d45d6cd
commit
fad3ba39c8
BIN
Assets/_DDD/_ScriptAssets/So/GoogleSheetSettingsSo.asset
(Stored with Git LFS)
BIN
Assets/_DDD/_ScriptAssets/So/GoogleSheetSettingsSo.asset
(Stored with Git LFS)
Binary file not shown.
@ -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
|
||||
{
|
||||
|
@ -4,6 +4,13 @@
|
||||
|
||||
namespace DDD
|
||||
{
|
||||
public enum RendererType
|
||||
{
|
||||
None = 0,
|
||||
Sprite = 1,
|
||||
Spine = 2,
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class EnvironmentData : IId
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -4,6 +4,13 @@
|
||||
|
||||
namespace DDD
|
||||
{
|
||||
public enum RecipeType
|
||||
{
|
||||
None = 0,
|
||||
FoodRecipe = 1,
|
||||
DrinkRecipe = 2,
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class RecipeData : IId
|
||||
{
|
||||
|
@ -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,
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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": ""
|
||||
},
|
||||
{
|
||||
|
BIN
Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/So/LevelDataSo.asset
(Stored with Git LFS)
BIN
Assets/_DDD/_Scripts/GenerateGoogleSheet/AutoCreated/So/LevelDataSo.asset
(Stored with Git LFS)
Binary file not shown.
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3392661ff91138a4991ec360e86907cb
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -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)
|
||||
{
|
||||
|
@ -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<string>(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<GoogleSheetChangeLog>(_settings.ChangeLogAssetPath);
|
||||
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
|
Loading…
Reference in New Issue
Block a user