From 74006824f8dc0df08788e6078120239f8f4602fc Mon Sep 17 00:00:00 2001 From: sator Date: Mon, 17 Feb 2020 00:17:40 +0900 Subject: [PATCH] Adding support for editor preview on non-windows platforms --- Assets/VRM.Samples/Scripts/VRMRuntimeExporter.cs | 2 ++ Assets/VRM.Samples/Scripts/VRMRuntimeLoader.cs | 10 ++++++++++ Assets/VRM.Samples/Scripts/ViewerUI.cs | 2 ++ 3 files changed, 14 insertions(+) diff --git a/Assets/VRM.Samples/Scripts/VRMRuntimeExporter.cs b/Assets/VRM.Samples/Scripts/VRMRuntimeExporter.cs index 2133365bf..7da329032 100644 --- a/Assets/VRM.Samples/Scripts/VRMRuntimeExporter.cs +++ b/Assets/VRM.Samples/Scripts/VRMRuntimeExporter.cs @@ -32,6 +32,8 @@ namespace VRM.Samples { #if UNITY_STANDALONE_WIN var path = FileDialogForWindows.FileDialog("open VRM", ".vrm"); +#elif UNITY_EDITOR + var path = UnityEditor.EditorUtility.OpenFilePanel("Open VRM", "", "vrm"); #else var path = Application.dataPath + "/default.vrm"; #endif diff --git a/Assets/VRM.Samples/Scripts/VRMRuntimeLoader.cs b/Assets/VRM.Samples/Scripts/VRMRuntimeLoader.cs index 3e4911286..95c4f0006 100644 --- a/Assets/VRM.Samples/Scripts/VRMRuntimeLoader.cs +++ b/Assets/VRM.Samples/Scripts/VRMRuntimeLoader.cs @@ -74,6 +74,8 @@ namespace VRM.Samples { #if UNITY_STANDALONE_WIN var path = FileDialogForWindows.FileDialog("open VRM", ".vrm"); +#elif UNITY_EDITOR + var path = UnityEditor.EditorUtility.OpenFilePanel("Open VRM", "", "vrm"); #else var path = Application.dataPath + "/default.vrm"; #endif @@ -115,6 +117,8 @@ namespace VRM.Samples { #if UNITY_STANDALONE_WIN var path = FileDialogForWindows.FileDialog("open VRM", ".vrm"); +#elif UNITY_EDITOR + var path = UnityEditor.EditorUtility.OpenFilePanel("Open VRM", "", "vrm"); #else var path = Application.dataPath + "/default.vrm"; #endif @@ -183,6 +187,12 @@ namespace VRM.Samples { LoadBvh(path); } +#elif UNITY_EDITOR + var path = UnityEditor.EditorUtility.OpenFilePanel("Open BVH", "", "bvh"); + if (!string.IsNullOrEmpty(path)) + { + LoadBvh(path); + } #else LoadBvh(Application.dataPath + "/default.bvh"); #endif diff --git a/Assets/VRM.Samples/Scripts/ViewerUI.cs b/Assets/VRM.Samples/Scripts/ViewerUI.cs index b97a26f22..a754a720b 100644 --- a/Assets/VRM.Samples/Scripts/ViewerUI.cs +++ b/Assets/VRM.Samples/Scripts/ViewerUI.cs @@ -259,6 +259,8 @@ namespace VRM.Samples { #if UNITY_STANDALONE_WIN var path = FileDialogForWindows.FileDialog("open VRM", "vrm", "glb", "bvh"); +#elif UNITY_EDITOR + var path = UnityEditor.EditorUtility.OpenFilePanel("Open VRM", "", "vrm"); #else var path = Application.dataPath + "/default.vrm"; #endif