using System.IO; using UnityEditor; namespace Live2D.Cubism.Editor { public class CubismUnityEditorUtility { /// /// Projectウィンドウで現在選択しているディレクトリのパスを取得。 /// Projectウィンドウ以外が選択されていたり、何も選択されていない場合、返す値はAssets直下。 /// /// Projectウィンドウで現在のディレクトリのパス public static string GetCurrentDirectoryPath() { var activeObject = Selection.activeObject; // [Unity6.5] GetInstanceID()가 obsolete error — GetAssetPath(EntityId) 오버로드로 교체. // SDK 5-r.5는 Unity 6.0 기준이라 미대응. 대응 버전이 나오면 이 줄을 되돌릴 것. var currentDirectoryPath = ((activeObject == null) ? "Assets" : AssetDatabase.GetAssetPath(activeObject.GetEntityId())); if (string.IsNullOrEmpty(currentDirectoryPath)) { currentDirectoryPath = "Assets"; } else if (!Directory.Exists(currentDirectoryPath)) { currentDirectoryPath = currentDirectoryPath.Replace("/" + Path.GetFileName(currentDirectoryPath), ""); } return currentDirectoryPath; } } }