DDD 프로젝트 일괄 설정 기능 추가

This commit is contained in:
NTG 2025-08-18 16:26:33 +09:00
parent d7c190fccf
commit a6ef8f9f8d
7 changed files with 130 additions and 0 deletions

8
Assets/_DDD/Editor.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c79b29ca9ae5a34458d2e83f21e6e2e9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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<DefaultAsset> 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} 프로젝트 동기화 완료");
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e5612e4bef4a5cf44b52eaa2739bbe33

View File

@ -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<ProjectDDD_Setup>(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;
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ab18775a9a68dee4c8326f7a3fdccf48

BIN
Assets/_DDD/ProjectDDD_Setup.asset (Stored with Git LFS) Normal file

Binary file not shown.

View File

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