61 lines
2.0 KiB
C#
61 lines
2.0 KiB
C#
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} 프로젝트 동기화 완료");
|
|
}
|
|
}
|
|
} |