Firebase in Unity WebGL build

别来无恙 提交于 2020-04-10 14:50:47

问题


Is there any way at all to use a realtime database in a Unity WebGL project?

If i understand right, the database unity SDK will work, but not the auth SDK, is that right? (Why is that, and is it likely to change in the near future?) The alternatives i can see are:

1) use the REST API to do auth (i've got this working in unity just using the WWW class), but then i can't see a way of using the auth token received from the REST API to authenticate with the database SDK.

2) write a WebGL plugin that uses the javascript SDK. Will this work? It could be quite a lot of extra work, and if you were also doing iOS/android builds, you'd have to check what platform you're on etc.


回答1:


You're right, the Firebase Unity SDK does not support the web target at this time.

As suggested by Stewart Miles from Google, to do this we should

taking our C# interface and using the Firebase JS SDK from C# when building for the web rather than using the REST API or any Unity SDKs that call our public REST APIs directly

So, this saying, you should go wiht your second option using Unity's built in JavaScript bindings to integrate directly with the Web SDK. It might come in handy to know how to call JavaScript functions from Unity scripts.



来源:https://stackoverflow.com/questions/46216440/firebase-in-unity-webgl-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!