빌드 했을때에도 폴더 경로 선택 탐색기를 사용할 수 있도록 수

This commit is contained in:
Mingu Kim
2025-12-24 23:27:25 +09:00
parent c7d637383f
commit 87a4a0b547

View File

@@ -27,23 +27,43 @@ public class DirectorySelect : MonoBehaviour
inputDirectory.text = basicDirectory;
}
private void OnSelect(string[] path)
private void OnSelect(string[] paths)
{
Debug.Log(path.ToString());
if (path.Length > 0)
// 사용자가 선택을 취소하지 않았는지 확인합니다.
if (paths != null && paths.Length > 0 && !string.IsNullOrEmpty(paths[0]))
{
selectedFolderPath = path[0];
// 1. 선택된 첫 번째 경로를 변수에 저장합니다.
selectedFolderPath = paths[0];
// 2. 화면에 표시되는 InputField 텍스트를 갱신합니다.
inputDirectory.text = selectedFolderPath;
// 3. 콘솔에 출력하여 확인합니다.
Debug.Log("선택된 폴더 경로: " + selectedFolderPath);
}
else
{
Debug.Log("폴더 선택이 취소되었습니다.");
}
}
public void Search()
{
// 유니티 에디터 자체 기능 사용 작동함...ㅠ
EditorUtility.OpenFolderPanel("디렉토리 선택", inputDirectory.text, "");
// 1. 깃허브 UnityStandaloneFileBrowser 에셋 방식 // https://github.com/tonidurans/UnityStandaloneFileBrowser/tree/master/Package
StandaloneFileBrowser.OpenFolderPanelAsync("디렉토리 선택", inputDirectory.text, false, OnSelect);
// StandaloneFileBrowser.OpenFolderPanelAsync("", "", false, OnSelect);
// 2. 유니티 에디터 자체 기능 사용 (게임 빌드했을때 정상 작동하지 않음)
// string path = EditorUtility.OpenFolderPanel("디렉토리 선택", inputDirectory.text, "");
//
// // 사용자가 취소를 누르지 않고 유효한 경로를 선택했을 때만 업데이트
// if (!string.IsNullOrEmpty(path))
// {
// inputDirectory.text = path;
// selectedFolderPath = inputDirectory.text;
// Debug.Log("선택된 경로: " + selectedFolderPath);
// }
// 3. DLL 라이브러리 방식
// // Windows
// if (UnityEngine.Application.platform == RuntimePlatform.WindowsPlayer ||
// UnityEngine.Application.platform == RuntimePlatform.WindowsEditor)