diff --git a/Assets/Scripts/DirectorySelect.cs b/Assets/Scripts/DirectorySelect.cs index 302cdf1..54ac418 100644 --- a/Assets/Scripts/DirectorySelect.cs +++ b/Assets/Scripts/DirectorySelect.cs @@ -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)