Unity WebGL データが保存されない

現象

結論

「サードパーティーのCookieをブロックする」にしていると保存されない。

結論に至るまでの調査

実行時に以下のエラー

[UnityCache] indexedDB database could not be opened

関連

https://forum.unity.com/threads/unitycache-indexeddb-database-could-not-be-opened-error.541215/

準備がタイムアウトした?

プレイヤー設定→WebGL→公開設定→データキャッシング

→エラーが以下に変わったが、まだ直らない

IndexedDB is not available. Data will not persist in cache and PlayerPrefs will not be saved.

UnityLoader.js のsetTimeoutを変更

→記述がないので修正済みと思われる

https://forum.unity.com/threads/playerprefs-will-not-be-saved.319348/

セキュリティの問題。開発者は動くはずという認識

Safariの問題という方向性

IndexDBではなくlocalStorageを使う

https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html

https://gomafrontier.com/unity/3955

→保存ファイルは Assets/Plugins/WebGL.jslib

→ローカル実行で保存は出来たが、UnityRoomではセキュリティエラー

修正

2026/02/22 更新しました。主な内容は変わっていません。

top

その他の投稿

20260103-01 Unity Entities Tips
20251231-01 Unity UI Toolkit カスタムコントロールサンプル
20250913-01 Unity アプリで Android 16KB ページサイズ確認
20250912-01 Unity 6 で Editor がちらつく問題
20250906-01 Win10サポート終了 ChromeOS Flex を入れてみてつまづいた所
20250812-02 Unity UI Toolkit でのタップ操作検出
20250812-01 Unity UI Toolkit でマップ画面 with RenderTexture
20250811-01 Unity UI Toolkit での座標変換
20250721-01 Unityでカメラが平行投影の場合にScreenToWorldPointがズレる
20250712-01 Unity既存プロジェクトにURP追加