mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-24 23:18:04 -05:00
fix SimpleViewer WebGL build
This commit is contained in:
parent
10dafaab49
commit
8108583f3e
|
|
@ -1,18 +1,20 @@
|
|||
mergeInto(LibraryManager.library, {
|
||||
WebGLFileDialog: function () {
|
||||
WebGLFileDialog: function (_target, _message) {
|
||||
const target = UTF8ToString(_target);
|
||||
const message = UTF8ToString(_message);
|
||||
const file_input_id = "file-input";
|
||||
var file_input = document.getElementById(file_input_id);
|
||||
if (!file_input) {
|
||||
file_input = document.createElement('input');
|
||||
file_input.setAttribute('type', 'file');
|
||||
file_input.setAttribute('id', file_input_id);
|
||||
// file_input.setAttribute('accept', '.vrm')
|
||||
file_input.style.visibility = 'hidden';
|
||||
file_input.onclick = function (event) {
|
||||
event.target.value = null;
|
||||
};
|
||||
file_input.onchange = function (event) {
|
||||
SendMessage('Canvas', 'FileSelected', URL.createObjectURL(event.target.files[0]));
|
||||
console.log('SendMessage', target, message);
|
||||
SendMessage(target, message, URL.createObjectURL(event.target.files[0]));
|
||||
}
|
||||
document.body.appendChild(file_input);
|
||||
}
|
||||
|
|
@ -8,8 +8,8 @@ namespace VRM.SimpleViewer
|
|||
return FileDialogForWindows.FileDialog(title, extensions);
|
||||
#elif UNITY_WEBGL
|
||||
// Open WebGLFileDialog
|
||||
// see: Assets\VRM_Samples\SimpleViewer\Plugins\OpenFile.jslib
|
||||
WebGLUtil.WebGLFileDialog();
|
||||
// see: Assets/UniGLTF/Runtime/Utils/Plugins/OpenFile.jslib
|
||||
WebGLUtil.WebGLFileDialog("Canvas", "FileSelected");
|
||||
// Control flow does not return here. return empty string with dummy
|
||||
return "";
|
||||
#elif UNITY_EDITOR
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace VRM.SimpleViewer
|
|||
public static class WebGLUtil
|
||||
{
|
||||
[DllImport("__Internal")]
|
||||
public static extern void WebGLFileDialog();
|
||||
public static extern void WebGLFileDialog(string target, string message);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -359,9 +359,9 @@ namespace VRM.SimpleViewer
|
|||
|
||||
IEnumerator LoadCoroutine(string url)
|
||||
{
|
||||
var www = new UnityEngine.Networking.UnityWebRequest(url);
|
||||
var www = new WWW(url);
|
||||
yield return www;
|
||||
var task = LoadBytesAsync("WebGL.vrm", www.downloadHandler.data);
|
||||
var task = LoadBytesAsync("WebGL.vrm", www.bytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace VRM.SimpleViewer
|
|||
#elif UNITY_WEBGL
|
||||
// Open WebGLFileDialog
|
||||
// see: Assets\VRM_Samples\SimpleViewer\Plugins\OpenFile.jslib
|
||||
WebGLUtil.WebGLFileDialog();
|
||||
WebGLUtil.WebGLFileDialog("Canvas", "FileSelected");
|
||||
// Control flow does not return here. return empty string with dummy
|
||||
return "";
|
||||
#elif UNITY_EDITOR
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace VRM.SimpleViewer
|
|||
public static class WebGLUtil
|
||||
{
|
||||
[DllImport("__Internal")]
|
||||
public static extern void WebGLFileDialog();
|
||||
public static extern void WebGLFileDialog(string target, string message);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -4,7 +4,6 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using UniGLTF;
|
||||
using UniGLTF.SpringBoneJobs;
|
||||
using UniHumanoid;
|
||||
using Unity.Collections;
|
||||
using UnityEngine;
|
||||
|
|
@ -294,8 +293,7 @@ namespace VRM.SimpleViewer
|
|||
|
||||
private void Start()
|
||||
{
|
||||
m_version.text = string.Format("VRMViewer {0}.{1}",
|
||||
PackageVersion.MAJOR, PackageVersion.MINOR);
|
||||
m_version.text = string.Format("VRMViewer {0}", PackageVersion.VERSION);
|
||||
m_open.onClick.AddListener(OnOpenClicked);
|
||||
|
||||
m_reset.onClick.AddListener(() => m_loaded?.ResetSpringbone());
|
||||
|
|
@ -313,6 +311,12 @@ namespace VRM.SimpleViewer
|
|||
}
|
||||
|
||||
m_texts.Start();
|
||||
|
||||
if (Application.platform == RuntimePlatform.WebGLPlayer)
|
||||
{
|
||||
m_useAsync.isOn = false;
|
||||
m_useAsync.interactable = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadMotion(string path, string source)
|
||||
|
|
@ -359,9 +363,9 @@ namespace VRM.SimpleViewer
|
|||
|
||||
IEnumerator LoadCoroutine(string url)
|
||||
{
|
||||
var www = new UnityEngine.Networking.UnityWebRequest(url);
|
||||
var www = new WWW(url);
|
||||
yield return www;
|
||||
var task = LoadBytesAsync("WebGL.vrm", www.downloadHandler.data);
|
||||
var task = LoadBytesAsync("WebGL.vrm", www.bytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -4,4 +4,8 @@
|
|||
EditorBuildSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Scenes: []
|
||||
m_Scenes:
|
||||
- enabled: 1
|
||||
path: Assets/VRM_Samples/SimpleViewer/SimpleViewer.unity
|
||||
guid: 5d0b0ec0bd1cdee4fbd25b64a6d059df
|
||||
m_configObjects: {}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user