본문 바로가기
개발/Unity

Unity)Editor - Project Current Directory Info(Project 현재 경로)

by 테샤르 2023. 5. 12.

Project Current Directory Info(Project 현재 경로)

프로젝트 브라우저 현재 디렉토리

내부 통합 정적 함수 내부에 숨겨져 ProjectWindowUtil.TryGetActiveFolderPath있으며 액

세스하려면  Reflection 이 필요하다.

 

 

<샘플 코드>

using UnityEngine;
using UnityEditor;
using System.Reflection;

    // Define this function somewhere in your editor class to make a shortcut to said hidden function
    private static bool TryGetActiveFolderPath( out string path )
    {
        var _tryGetActiveFolderPath = typeof(ProjectWindowUtil).GetMethod( "TryGetActiveFolderPath", BindingFlags.Static | BindingFlags.NonPublic );

        object[] args = new object[] { null };
        bool found = (bool)_tryGetActiveFolderPath.Invoke( null, args );
        path = (string)args[0];

        return found;
    }

 

 

반응형

 

Custom 을 진행하기 위해서는 내부 소스 코드를 참고하면 꽤나 많은 것들에 대한 아이디어와 활용이 가능하다.

 

 

 

Unity ProjectWindow/ProjectWindowUtil.cs : [링크]

 

GitHub - Unity-Technologies/UnityCsReference: Unity C# reference source code.

Unity C# reference source code. Contribute to Unity-Technologies/UnityCsReference development by creating an account on GitHub.

github.com

 

원본 링크 : [링크]

 

Getting path of right click in unity 3D editor

I want to create an extension for the Unity 3D Editor and have an custom asset type. During the process of creation this I recognized that I would improve the UX/usability if I can specify the path...

gamedev.stackexchange.com

 

★☆☆☆☆

 

반응형

댓글