Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase in Unity WebGL build

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.

like image 289
jonydep Avatar asked Oct 29 '22 02:10

jonydep


1 Answers

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 with 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.

like image 101
Tiago Martins Peres Avatar answered Jan 02 '23 19:01

Tiago Martins Peres