Firebase – Unity的离线行为

我最近开始使用Firebase开发我的游戏,并在一个地方考虑​​Firebase提供的几乎所有功能.但现在我面临一些限制/实施问题,所以任何帮助将不胜感激.

我正在开发一款半在线游戏,只要没有可用的网络,用户就可以玩游戏,并在连接时立即与Firebase同步.对于第一次启动连接是强制性的,因为我要从Firebase提取配置数据,以后用户可以使用离线保存状态,这将在以后连接时推送.

如果我误解了任何实现,我对Firebase非常赞不绝口.我查看了不同的答案,主要是针对本机Android / iOS,而不是针对Unity.所以要么我找不到答案,要么几年前才被问到但仍然没有回答.谢谢!

最佳答案 老问题但仍难以找到正确的答案.

Firebase文档明确含糊不清:在此页面上:

https://firebase.google.com/docs/database/unity/start

第一行:

“Firebase实时数据库存储并与我们的NoSQL云数据库同步数据.数据实时同步到所有客户端,并在您的应用程序脱机时保持可用.”

Unity Firebase不支持真正的脱机功能.
仅当您的游戏以网络开启时才会起作用,并且在播放时,如果播放器已关闭网络,只要您在停止游戏前打开网络,它就会正常运行!所以它可以同步..否则所有的变化都会丢失!

以下是来自firebase对这个问题的支持的答案:

Currently, Unity doesn’t support offline capability. Apologies about this. This is indeed something we’re looking into, however, I cannot guarantee that this will be available anytime soon. We’ll keep your feedback in consideration moving forward.

The documentation is explaining that your app will continue to save your data while offline. When data is written, it’s written to this local version first and synchronizes that data to the server once connectivity is reestablished. Check 07001 for more details. For additional context, Firebase’s network resilience will work on Unity. So as long as the app stays active, Firebase will continue functioning if the network connection drops. In that case it serves any reads from its cache and keeps a queue of pending writes. But currently there is no support for disk persistence, which would allow the cache and queue to survive during app restarts.

点赞