From a6ef8f9f8dca9da9c2937244e37110164db95bbc Mon Sep 17 00:00:00 2001 From: NTG Date: Mon, 18 Aug 2025 16:26:33 +0900 Subject: [PATCH] =?UTF-8?q?DDD=20=ED=94=84=EB=A1=9C=EC=A0=9D=ED=8A=B8=20?= =?UTF-8?q?=EC=9D=BC=EA=B4=84=20=EC=84=A4=EC=A0=95=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/_DDD/Editor.meta | 8 +++ Assets/_DDD/Editor/ProjectDDD_Setup.cs | 61 +++++++++++++++++++++ Assets/_DDD/Editor/ProjectDDD_Setup.cs.meta | 2 + Assets/_DDD/Editor/ProjectSetupMenu.cs | 46 ++++++++++++++++ Assets/_DDD/Editor/ProjectSetupMenu.cs.meta | 2 + Assets/_DDD/ProjectDDD_Setup.asset | 3 + Assets/_DDD/ProjectDDD_Setup.asset.meta | 8 +++ 7 files changed, 130 insertions(+) create mode 100644 Assets/_DDD/Editor.meta create mode 100644 Assets/_DDD/Editor/ProjectDDD_Setup.cs create mode 100644 Assets/_DDD/Editor/ProjectDDD_Setup.cs.meta create mode 100644 Assets/_DDD/Editor/ProjectSetupMenu.cs create mode 100644 Assets/_DDD/Editor/ProjectSetupMenu.cs.meta create mode 100644 Assets/_DDD/ProjectDDD_Setup.asset create mode 100644 Assets/_DDD/ProjectDDD_Setup.asset.meta diff --git a/Assets/_DDD/Editor.meta b/Assets/_DDD/Editor.meta new file mode 100644 index 000000000..39fb3a247 --- /dev/null +++ b/Assets/_DDD/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c79b29ca9ae5a34458d2e83f21e6e2e9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_DDD/Editor/ProjectDDD_Setup.cs b/Assets/_DDD/Editor/ProjectDDD_Setup.cs new file mode 100644 index 000000000..3628da1ee --- /dev/null +++ b/Assets/_DDD/Editor/ProjectDDD_Setup.cs @@ -0,0 +1,61 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Sirenix.OdinInspector; +using UnityEditor; +using UnityEngine; + +namespace DDD +{ + [CreateAssetMenu(menuName = "DDD/Project Setup Config", fileName = "ProjectDDD_Setup")] + public sealed class ProjectDDD_Setup : ScriptableObject + { + // 로그 프리픽스는 상수로 관리 + private const string LogPrefix = "[DDD]"; + + public List DefaultAssets = new(); + public GoogleSheetManager GoogleSheetManager; + + [Button("프로젝트 동기화")] + public async Task SyncProject() + { + Debug.Log($"{LogPrefix} 프로젝트 동기화 시작"); + + foreach (var asset in DefaultAssets) + { + // 해당 폴더 reimport 하고 완료될 때까지 대기 + if (asset != null) + { + string assetPath = AssetDatabase.GetAssetPath(asset); + Debug.Log($"{LogPrefix} 에셋 재임포트 시작: {asset.name}"); + + // 폴더의 경우 수동 Reimport와 동일하게 재귀 옵션을 추가하고 + // 동기식 강제 임포트로 Import가 완료될 때까지 대기하도록 처리 + var importOptions = ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport; + if (AssetDatabase.IsValidFolder(assetPath)) + { + importOptions |= ImportAssetOptions.ImportRecursive; + } + AssetDatabase.ImportAsset(assetPath, importOptions); + + Debug.Log($"{LogPrefix} 에셋 재임포트 완료: {asset.name}"); + } + } + + Debug.Log($"{LogPrefix} Google Sheet 동기화 시작"); + if (GoogleSheetManager != null) + { + await GoogleSheetManager.SyncSoOnlyFromCurrentJson(); + } + else + { + Debug.LogWarning($"{LogPrefix} GoogleSheetManager가 설정되어 있지 않습니다. Google Sheet 동기화를 건너뜁니다."); + } + Debug.Log($"{LogPrefix} Google Sheet 동기화 완료"); + + // 에셋 데이터베이스 최신화 보장 (수동 Reimport 후 상태와 유사하게 유지) + AssetDatabase.Refresh(); + + Debug.Log($"{LogPrefix} 프로젝트 동기화 완료"); + } + } +} \ No newline at end of file diff --git a/Assets/_DDD/Editor/ProjectDDD_Setup.cs.meta b/Assets/_DDD/Editor/ProjectDDD_Setup.cs.meta new file mode 100644 index 000000000..fa16e9c0d --- /dev/null +++ b/Assets/_DDD/Editor/ProjectDDD_Setup.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: e5612e4bef4a5cf44b52eaa2739bbe33 \ No newline at end of file diff --git a/Assets/_DDD/Editor/ProjectSetupMenu.cs b/Assets/_DDD/Editor/ProjectSetupMenu.cs new file mode 100644 index 000000000..5e4ab12bd --- /dev/null +++ b/Assets/_DDD/Editor/ProjectSetupMenu.cs @@ -0,0 +1,46 @@ +using System.Linq; +using UnityEditor; +using UnityEngine; + +namespace DDD +{ + public static class ProjectSetupMenu + { + private const string MenuPath = "Tools/Project Setup"; + + [MenuItem(MenuPath)] + public static void OpenSetupByType() + { + var guids = AssetDatabase.FindAssets("t:" + nameof(ProjectDDD_Setup)); + if (guids == null || guids.Length == 0) + { + EditorUtility.DisplayDialog( + "Project Setup", + $"타입 '{nameof(ProjectDDD_Setup)}'의 자산을 찾을 수 없습니다.\n" + + "아래 메뉴로 새 자산을 생성하고 원하는 위치에 보관하세요:\n" + + $"Create > {GetCreateMenuName()}", + "확인"); + return; + } + + var path = AssetDatabase.GUIDToAssetPath(guids.First()); + var asset = AssetDatabase.LoadAssetAtPath(path); + Selection.activeObject = asset; + EditorGUIUtility.PingObject(asset); + } + + private static string GetCreateMenuName() + { + var attributes = typeof(ProjectDDD_Setup).GetCustomAttributes(typeof(CreateAssetMenuAttribute), false); + if (attributes != null && attributes.Length > 0) + { + var attr = (CreateAssetMenuAttribute)attributes[0]; + return string.IsNullOrEmpty(attr.menuName) ? typeof(ProjectDDD_Setup).Name : attr.menuName; + } + + return typeof(ProjectDDD_Setup).Name; + } + } +} + + diff --git a/Assets/_DDD/Editor/ProjectSetupMenu.cs.meta b/Assets/_DDD/Editor/ProjectSetupMenu.cs.meta new file mode 100644 index 000000000..54b78bdc0 --- /dev/null +++ b/Assets/_DDD/Editor/ProjectSetupMenu.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ab18775a9a68dee4c8326f7a3fdccf48 \ No newline at end of file diff --git a/Assets/_DDD/ProjectDDD_Setup.asset b/Assets/_DDD/ProjectDDD_Setup.asset new file mode 100644 index 000000000..5011bbcff --- /dev/null +++ b/Assets/_DDD/ProjectDDD_Setup.asset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:046d16969d2d5c1cbedb87c69d7ae9c4897f086f5874c9180585105723d21b07 +size 731 diff --git a/Assets/_DDD/ProjectDDD_Setup.asset.meta b/Assets/_DDD/ProjectDDD_Setup.asset.meta new file mode 100644 index 000000000..4f5001036 --- /dev/null +++ b/Assets/_DDD/ProjectDDD_Setup.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 259a2f6a47e3c5746af8c65f213597a0 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: