Use the file selection screen in Unity
↓ I want to select a file using a dialog box like this: thinking:
Script
script
using UnityEditor;
public void OpenFile()
{
//Get the path
var path = EditorUtility.OpenFilePanel("Open csv", "", "CSV");
if (string.IsNullOrEmpty(path))
return;
Debug.Log(path);
//Read
var reader = new StreamReader(path);
Debug.Log(reader);
}
Details // Show dialog box here
Select one file
script
var path = EditorUtility.OpenFilePanel("Open csv", "", "CSV");
var path = EditorUtility.OpenFilePanel(Dialog box name,Directory default settings,File extension to read);
When specifying multiple types of file extensions
script
var path = EditorUtility.OpenFilePanelWithFilters("Open image", "", {"Music file","mp3,ogg,wav"});
EditorUtility.OpenFilePanelWithFilters
When selecting a folder
script
var path = EditorUtility.OpenFolderPanel("Open Folder", "", "");