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; } } }