Preparar
Github:ookii-dialogs-winforms , descarga el archivo con el sufijo nupkg, modifica el sufijo a rar, descomprime y abre para encontrar Ookii.Dialogs.WinForms.dll
Cree un nuevo archivo css.rsp en el directorio Activos, el contenido del archivo es: -r:System.Windows.Forms.dll
Ajuste de nivel de API para .NET Framework
Unidad versión 2021.3.6f1c1
usar
using Ookii. Dialogs. WinForms ;
using System. Runtime. InteropServices ;
using System. Windows. Forms ;
using System ;
using UnityEngine ;
public class Dialog
{
[ DllImport ( "user32.dll" ) ]
private static extern IntPtr GetActiveWindow ( ) ;
public void OpenWindowFolder ( )
{
var openFileDialog = new VistaOpenFileDialog ( ) ;
openFileDialog. Multiselect = false ;
openFileDialog. Title = "Open Folder" ;
openFileDialog. InitialDirectory = "D:\\" ;
openFileDialog. RestoreDirectory = false ;
openFileDialog. FilterIndex = 1 ;
openFileDialog. Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png" ;
try
{
if ( openFileDialog. ShowDialog ( new WindowFolder ( GetActiveWindow ( ) ) ) == DialogResult. OK)
{
Debug. Log ( openFileDialog. FileName) ;
for ( int i = 0 ; i < openFileDialog. FileNames. Length; i++ )
{
Debug. Log ( "路径" + openFileDialog. FileNames[ i] ) ;
}
}
}
catch ( Exception e)
{
Debug. Log ( e. StackTrace) ;
Debug. Log ( e. Source) ;
Debug. Log ( e. Message) ;
}
}
}
using System ;
using System. Windows. Forms ;
public class WindowFolder : IWin32Window
{
IntPtr handle;
public WindowFolder ( IntPtr handle)
{
this . handle = handle;
}
public IntPtr Handle
{
get {
return handle; }
}
}
prueba
if ( GUILayout. Button ( "test" ) )
{
var dialog = new Dialog ( ) ;
dialog. OpenWindowFolder ( ) ;
}