Open mad-jose opened 1 year ago
Please provide a minimal reproduction. Thanks.
Please provide a minimal reproduction. Thanks.
here is a sample code https://github.com/maddevjose/tauri-unity-bug
@maddevjose can you try the following and see if it works?
In Unity under Project Settings -> Player -> Publishing Settings
afaik this is potentially a limitation of Unity itself
@maddevjose can you try the following and see if it works?
In Unity under Project Settings -> Player -> Publishing Settings
- Try different Compression Format
- Try enable Decompression Fallback
afaik this is potentially a limitation of Unity itself
it still does not work build. It works in yarn tauri dev
@maddevjose can you try the following and see if it works? In Unity under Project Settings -> Player -> Publishing Settings
- Try different Compression Format
- Try enable Decompression Fallback
afaik this is potentially a limitation of Unity itself
it still does not work build. It works in yarn tauri dev
i added .setup(move |app| { let resource_path = app.path_resolver().resolve_resource("UnityWebGlTest/").expect("failed to resolve resource"); let resource_path_string = resource_path.to_str().unwrap().to_owned(); let server = thread::spawn( move || { let sys = actixrt::System::new(); let = HttpServer::new(move || { App::new().service(fs::Files::new("/UnityWebGlTest", resource_path_string.clone()).show_fileslisting()) }) .bind("127.0.0.1:8000") .unwrap() .run(); let = sys.run(); });
Ok(())
})
in main.rs
moved UnityWebGlTest into src-tauri
and added "resources": [ "UnityWebGlTest/*" ], in tauri.conf.json. hoping to load it from the localhost:8000 but it is not getting hosted there
yikes, I wasted an hour trying to debug and fix this only to discover you're using an iframe which is the root cause of the problem. So it is duplicate of #7114, basically requests from within the iframe doesn't reach our internal server. We are waiting for microsoft to release the new API in stable WebView2.
yikes, I wasted an hour trying to debug and fix this only to discover you're using an iframe which is the root cause of the problem. So it is duplicate of #7114, basically requests from within the iframe doesn't reach our internal server. We are waiting for microsoft to release the new API in stable WebView2.
so i could potentially use actix_web and add resources in config and self host it and call it via iframe right? that is what i tried before,
usually I won't recommend using a localhost server but for this use-case there is no other workarounds at the moment
How to achieve this function, can you guide me
you could try using tauri-plugin-localhost
or bundle the unity files as resources and use any rust server to serve them.
Are you hosting the build files on your device?
I just got the unity web app working in tauri (release build) by simply putting all the build files in the root static folder (all webeditor
files are in the /static/
folder) and setting my config like this:
const config = {
dataUrl: '/webeditor.data',
frameworkUrl: '/webeditor.framework.js',
codeUrl: '/webeditor.wasm',
StreamingAssetsUrl: null,
companyName: "com.somecompany.test",
productName: "0.1.0",
showBanner: null
}
and applying it like this:
canvasElement = document.querySelector("#unity-canvas");
const unityScript = document.createElement('script');
unityScript.src = "/webeditor.loader.js";
unityScript.onload = () => {
console.log("loading unity...");
createUnityInstance(canvasElement, config, (progress) => {
console.log(progress);
}).then((instance) => {
unityInstance = instance;
}).catch((msg) => {
console.log(msg);
});
}
document.body.appendChild(unityScript);
}
This is all without a localhost, using the plugin or iframes. I am not sure if this helps you for a workaround, but id be happy to assist if there is further trouble.
Describe the bug
I exported a unity app as webgl, added it to the public folder loaded it using iframe
In the browser, it works but in tauri app it does not work. doing build for windows
In tauri app it displays: Unable to parse Build/UnityWebGlTest.framework.js.br! This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: br" present. Check browser Console and Devtools Network tab to debug.
Reproduction
exported a unity app as webgl, added it to the public folder loaded it using iframe
https://github.com/maddevjose/tauri-unity-bug yarn run bld
Expected behavior
unity loads
Platform and versions
Stack trace
No response
Additional context
in tauri dev it works build is the issue