mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-24 11:35:24 -05:00
jslib
This commit is contained in:
@@ -7,9 +7,9 @@ namespace VRM.SimpleViewer
|
||||
#if UNITY_STANDALONE_WIN
|
||||
return FileDialogForWindows.FileDialog(title, extensions);
|
||||
#elif UNITY_WEBGL
|
||||
// Open UniVRM_Sample_WebGLFileDialog
|
||||
// Open WebGL_VRM0X_SimpleViewer_FileDialog
|
||||
// see: Assets/UniGLTF/Runtime/Utils/Plugins/OpenFile.jslib
|
||||
WebGLUtil.UniVRM_Sample_WebGLFileDialog("Canvas", "FileSelected");
|
||||
WebGLUtil.WebGL_VRM0X_SimpleViewer_FileDialog("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 UniVRM_Sample_WebGLFileDialog(string target, string message);
|
||||
public static extern void WebGL_VRM0X_SimpleViewer_FileDialog(string target, string message);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
8
Assets/VRM_Samples/SimpleViewer/Plugins.meta
Normal file
8
Assets/VRM_Samples/SimpleViewer/Plugins.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 453de3a4f46d44d4087a1fca730e04d5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
mergeInto(LibraryManager.library, {
|
||||
WebGL_VRM0X_SimpleViewer_FileDialog: 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.style.visibility = 'hidden';
|
||||
file_input.onclick = function (event) {
|
||||
event.target.value = null;
|
||||
};
|
||||
file_input.onchange = function (event) {
|
||||
console.log('SendMessage', target, message);
|
||||
SendMessage(target, message, URL.createObjectURL(event.target.files[0]));
|
||||
}
|
||||
document.body.appendChild(file_input);
|
||||
}
|
||||
file_input.click();
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef25d97dc58954a4ca17b4173225e58f
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
WebGL: WebGL
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user