diff --git a/Assets/_DDD/_Scripts/GenerateGoogleSheet/Core/GoogleSheetManager.cs b/Assets/_DDD/_Scripts/GenerateGoogleSheet/Core/GoogleSheetManager.cs index e82c86284..68ce067af 100644 --- a/Assets/_DDD/_Scripts/GenerateGoogleSheet/Core/GoogleSheetManager.cs +++ b/Assets/_DDD/_Scripts/GenerateGoogleSheet/Core/GoogleSheetManager.cs @@ -9,13 +9,10 @@ using UnityEngine; using Newtonsoft.Json.Linq; using System.Linq; -using DDD; using JetBrains.Annotations; using Sirenix.OdinInspector; using UnityEditor; using UnityEngine.AddressableAssets; -using UnityEngine.ResourceManagement.AsyncOperations; -using UnityEngine.U2D; using ColorUtility = UnityEngine.ColorUtility; public class GoogleSheetManager : Singleton @@ -33,8 +30,8 @@ public class GoogleSheetManager : Singleton private string _namespace = "DDD"; [BoxGroup("기본 설정")] - [SerializeField, Tooltip("적용시킬 시트의 이름을 적고, 여러 개의 시트를 적는 경우 '/'로 구분지어 시트 나열\nex) \"Sheet1/Sheet2\"")] - private string _availSheets = "Sheet1/Sheet2"; + [SerializeField, Tooltip("적용시킬 시트의 이름들")] + private List _availSheets = new(){ "Sheet1", "Sheet2" }; [BoxGroup("기본 설정")] [SerializeField, Tooltip("Class, Json, So 생성 위치 \"/GenerateGoogleSheet\"")] @@ -70,28 +67,11 @@ public class GoogleSheetManager : Singleton private bool _alreadyCreatedSo; - public static async Task LoadSo() where T : ScriptableObject - { - await Addressables.InitializeAsync().Task; - - string key = typeof(T).Name; - var handle = Addressables.LoadAssetAsync(key); - await handle.Task; - - if (handle.Status == AsyncOperationStatus.Succeeded) - return handle.Result; - - Debug.LogError($"[GoogleSheetManager] Addressable 로드 실패: {key}"); - return null; - } - #if UNITY_EDITOR || DEVELOPMENT_BUILD [BoxGroup("데이터 변경")] [Button("데이터 최신화"), EnableIf(nameof(CanFetchData))] private async Task FetchGoogleSheet() { - _availSheetArray = _availSheets.Split('/'); - var prevLog = AssetDatabase.LoadAssetAtPath(ChangeLogAssetPath); string previousJson = prevLog?.Logs.LastOrDefault()?.JsonSnapshot ?? ""; @@ -333,7 +313,7 @@ private bool SaveFileOrSkip(string path, string contents) private bool IsExistAvailSheets(string sheetName) { - return Array.Exists(_availSheetArray, x => x == sheetName); + return _availSheets.Contains(sheetName); } /// @@ -366,6 +346,9 @@ private void GenerateClassFilesPerSheet(string jsonInput) { string rawName = property.Name; string enumType = null; + + // 🔽 #으로 시작하는 보기용 컬럼은 무시 + if (rawName.StartsWith("#")) continue; // ✅ 단일 필드 Enum: Cookware:Enum if (rawName.Contains(":Enum")) @@ -480,51 +463,49 @@ private string GenerateDataClassCode(string className, JArray items) sb.AppendLine($" public class {className} : IId"); sb.AppendLine(" {"); - int count = sampleRow.Properties().Count(); - string[] types = new string[count]; - string[] names = new string[count]; - string[] tooltips = new string[count]; + List types = new(); + List names = new(); + List tooltips = new(); - foreach (JToken item in items.Skip(1)) + foreach (var prop in sampleRow.Properties()) { - int i = 0; - foreach (var prop in ((JObject)item).Properties()) + string rawName = prop.Name; + + // 무시할 컬럼이면 continue + if (rawName.StartsWith("#")) continue; + + string fieldName = rawName; + string explicitType = null; + + if (rawName.Contains(":Enum")) { - string rawName = prop.Name; - string fieldName = rawName; - string explicitType = null; - - if (rawName.Contains(":Enum")) - { - fieldName = rawName.Split(':')[0]; - explicitType = fieldName; - } - else if (rawName.Contains(":") && rawName.EndsWith("_Enum")) - { - var parts = rawName.Split(':'); - fieldName = parts[0]; - explicitType = parts[1].Replace("_Enum", ""); - } - else if (rawName.Contains(":NativeEnum")) - { - fieldName = rawName.Split(':')[0]; - explicitType = fieldName; - } - else if (rawName.Contains(":")) - { - var parts = rawName.Split(':'); - fieldName = parts[0]; - explicitType = parts[1]; - } - - types[i] = explicitType ?? GetCSharpType(prop.Value.Type); - names[i] = fieldName; - tooltips[i] ??= commentRow.TryGetValue(rawName, out var tip) ? tip.ToString() : ""; - i++; + fieldName = rawName.Split(':')[0]; + explicitType = fieldName; } + else if (rawName.Contains(":") && rawName.EndsWith("_Enum")) + { + var parts = rawName.Split(':'); + fieldName = parts[0]; + explicitType = parts[1].Replace("_Enum", ""); + } + else if (rawName.Contains(":NativeEnum")) + { + fieldName = rawName.Split(':')[0]; + explicitType = fieldName; + } + else if (rawName.Contains(":")) + { + var parts = rawName.Split(':'); + fieldName = parts[0]; + explicitType = parts[1]; + } + + types.Add(explicitType ?? GetCSharpType(prop.Value.Type)); + names.Add(fieldName); + tooltips.Add(commentRow.TryGetValue(rawName, out var tip) ? tip.ToString() : ""); } - for (int i = 0; i < count; i++) + for (int i = 0; i < names.Count; i++) { if (!string.IsNullOrWhiteSpace(tooltips[i])) { @@ -671,6 +652,9 @@ private async Task InternalCreateGoogleSheetSoAsync() string rawName = prop.Name; string fieldName = rawName; string explicitType = null; + + // 🔽 보기용 컬럼 무시 + if (rawName.StartsWith("#")) continue; if (rawName.Contains(":Enum")) {