mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-15 23:27:19 -05:00
jslib
This commit is contained in:
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@@ -56,5 +56,8 @@
|
||||
"Scriptable",
|
||||
"UNIVRM"
|
||||
],
|
||||
"dotnet.defaultSolution": "UniVRM.sln"
|
||||
"dotnet.defaultSolution": "UniVRM.sln",
|
||||
"files.associations": {
|
||||
"*.jslib": "javascript",
|
||||
}
|
||||
}
|
||||
@@ -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:
|
||||
@@ -1,5 +1,5 @@
|
||||
mergeInto(LibraryManager.library, {
|
||||
UniVRM_Sample_WebGLFileDialog: function (_target, _message) {
|
||||
WebGL_VRM10_VRM10Viewer_FileDialog: function (_target, _message) {
|
||||
const target = UTF8ToString(_target);
|
||||
const message = UTF8ToString(_message);
|
||||
const file_input_id = "file-input";
|
||||
@@ -641,16 +641,16 @@ namespace UniVRM10.VRM10Viewer
|
||||
}
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UniVRM_Sample_WebGLFileDialog(string target, string message);
|
||||
public static extern void WebGL_VRM10_VRM10Viewer_FileDialog(string target, string message);
|
||||
|
||||
string FileDialog()
|
||||
{
|
||||
#if UNITY_STANDALONE_WIN
|
||||
return VRM10FileDialogForWindows.FileDialog("open VRM", "vrm");
|
||||
#elif UNITY_WEBGL
|
||||
// Open UniVRM_Sample_WebGLFileDialog
|
||||
// Open WebGL_VRM10_VRM10Viewer_FileDialog
|
||||
// see: Assets/UniGLTF/Runtime/Utils/Plugins/OpenFile.jslib
|
||||
UniVRM_Sample_WebGLFileDialog("Canvas", "FileSelected");
|
||||
WebGL_VRM10_VRM10Viewer_FileDialog("Canvas", "FileSelected");
|
||||
// Control flow does not return here. return empty string with dummy
|
||||
return null;
|
||||
#elif UNITY_EDITOR
|
||||
|
||||
8
Assets/VRM10_Samples/VRM10Viewer/Plugins.meta
Normal file
8
Assets/VRM10_Samples/VRM10Viewer/Plugins.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a75c9f76297d99041bdf9ca2458d12bb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
mergeInto(LibraryManager.library, {
|
||||
WebGL_VRM10_VRM10Viewer_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: 2e8941ad33d65584f8ef2f8b829a05e7
|
||||
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:
|
||||
@@ -641,16 +641,16 @@ namespace UniVRM10.VRM10Viewer
|
||||
}
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UniVRM_Sample_WebGLFileDialog(string target, string message);
|
||||
public static extern void WebGL_VRM10_VRM10Viewer_FileDialog(string target, string message);
|
||||
|
||||
string FileDialog()
|
||||
{
|
||||
#if UNITY_STANDALONE_WIN
|
||||
return VRM10FileDialogForWindows.FileDialog("open VRM", "vrm");
|
||||
#elif UNITY_WEBGL
|
||||
// Open UniVRM_Sample_WebGLFileDialog
|
||||
// Open WebGL_VRM10_VRM10Viewer_FileDialog
|
||||
// see: Assets/UniGLTF/Runtime/Utils/Plugins/OpenFile.jslib
|
||||
UniVRM_Sample_WebGLFileDialog("Canvas", "FileSelected");
|
||||
WebGL_VRM10_VRM10Viewer_FileDialog("Canvas", "FileSelected");
|
||||
// Control flow does not return here. return empty string with dummy
|
||||
return null;
|
||||
#elif UNITY_EDITOR
|
||||
|
||||
@@ -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