Merge pull request #2569 from ousttrue/fix/webgl_dialog

[WebGL] Dialogの優先順位。Editor は UNITY_EDITOR
This commit is contained in:
ousttrue
2025-01-29 13:54:17 +09:00
committed by GitHub
2 changed files with 9 additions and 9 deletions

View File

@@ -645,7 +645,9 @@ namespace UniVRM10.VRM10Viewer
string FileDialog()
{
#if UNITY_STANDALONE_WIN
#if UNITY_EDITOR
return UnityEditor.EditorUtility.OpenFilePanel("Open VRM", "", "vrm");
#elif UNITY_STANDALONE_WIN
return VRM10FileDialogForWindows.FileDialog("open VRM", "vrm");
#elif UNITY_WEBGL
// Open WebGL_VRM10_VRM10Viewer_FileDialog
@@ -653,8 +655,6 @@ namespace UniVRM10.VRM10Viewer
WebGL_VRM10_VRM10Viewer_FileDialog("Canvas", "FileSelected");
// Control flow does not return here. return empty string with dummy
return null;
#elif UNITY_EDITOR
return UnityEditor.EditorUtility.OpenFilePanel("Open VRM", "", "vrm");
#else
return Application.dataPath + "/default.vrm";
#endif

View File

@@ -4,7 +4,12 @@ namespace VRM.SimpleViewer
{
public static string OpenFileDialog(string title, params string[] extensions)
{
#if UNITY_STANDALONE_WIN
#if UNITY_EDITOR
// EditorUtility.OpenFilePanel
// TODO: How to specify multiple extensions on OSX?
// https://github.com/vrm-c/UniVRM/issues/1837
return UnityEditor.EditorUtility.OpenFilePanel(title, "", extensions[0]);
#elif UNITY_STANDALONE_WIN
return FileDialogForWindows.FileDialog(title, extensions);
#elif UNITY_WEBGL
// Open WebGL_VRM0X_SimpleViewer_FileDialog
@@ -12,11 +17,6 @@ namespace VRM.SimpleViewer
WebGLUtil.WebGL_VRM0X_SimpleViewer_FileDialog("Canvas", "FileSelected");
// Control flow does not return here. return empty string with dummy
return "";
#elif UNITY_EDITOR
// EditorUtility.OpenFilePanel
// TODO: How to specify multiple extensions on OSX?
// https://github.com/vrm-c/UniVRM/issues/1837
return UnityEditor.EditorUtility.OpenFilePanel(title, "", extensions[0]);
#else
// fall back constant path
UnityEngine.Debug.LogWarning("Non-Windows runtime file dialogs are not yet implemented.");