pixijs/spine

[unity] I can't load the locally saved 'spine' file.

expellee opened this issue · 0 comments

I am using UniWebview in unity.

I make a simple web game with pixijs,
Save the web game locally (Android pad) in Unity,
I want to make it run.

There are two problems.
1, @pixi/sound doesn't work properly.
2. the biggest problem for me, I can't load the locally saved 'spine' file.

The package.json of web contents is as follows.

{
   "name": "test_webview_game",
   "private": true,
   "version": "0.0.0",
   "type": "module",
   "scripts": {
     "dev": "vite",
     "build": "vite build",
     "preview": "vite preview"
   },
   "devDependencies": {
     "vite": "^4.3.9"
   },
   "dependencies": {
     "@pixi/particle-emitter": "^5.0.8",
     "@pixi/sound": "^5.2.0",
     "pixi-spine": "^4.0.4",
     "pixi.js": "^7.2.4"
   }
}

The spine code was written in two ways. Both don't work.
1.

PIXI.Assets.add("json", "assets/bbb/alien.json");
PIXI.Assets.add("atlas", "assets/bbb/alien.atlas");
PIXI.Assets.load(["json", "atlas"]);

const animation = Spine.from("json", "atlas");
const alien = await PIXI.Assets.load('assets/bbb/alien.json');
const animation = new Spine(alien.spineData);

When running on server it works fine.
When running with 'vite run dev', it works fine.
After building, it is not executed after saving to the local of Unity (Android pad).

Both of them give the same error as the below.
Error: [Loader.load] Failed to load file:///storage/emulated/0/Android/data/com.test.webviewcontent/files/web/test_webview_game/assets/bbb/alien.json.
TypeError: Failed to fetch

The uniwebview options are set as follows.

UniWebView.SetJavaScriptEnabled
UniWebView.SetAllowAutoPlay
UniWebView.SetAllowJavaScriptOpenWindow
UniWebView.SetAllowInlinePlay
UniWebView.SetAllowUniversalAccessFromFileURLs
webView.SetUseWideViewPort
webView.SetLoadWithOverviewMode webView.SetAcceptThirdPartyCookies
webView.SetLoadWithOverviewMode

If anyone knows a solution, please help.

Have a good day.