Unity WebGL构建中的Firebase [英] Firebase in Unity WebGL build

查看:118
本文介绍了Unity WebGL构建中的Firebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在Unity WebGL项目中使用实时数据库?

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

如果我理解正确,那么数据库统一SDK将可以运行,但auth SDK不能运行,对吗? (为什么会这样,并且在不久的将来可能会发生变化?)我可以看到的替代方法是:

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)使用REST API进行身份验证(我只使用WWW类就可以做到这一点),但是我看不到使用从REST API接收到的auth令牌进行身份验证的方法数据库SDK.

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)编写一个使用javascript SDK的WebGL插件.这会工作吗?可能会有很多额外的工作,而且如果您还在进行iOS/android构建,则必须检查所使用的平台等.

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.

推荐答案

是的,Firebase Unity SDK目前不支持网络目标.

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

根据Google的 Stewart Miles 的建议,我们应该这样做

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

采用我们的C#界面,并在C#上使用 Firebase JS SDK 为Web构建而不是使用REST API或任何Unity SDK 直接调用我们的公共REST API

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

因此,这句话,您应该使用Unity的内置JavaScript绑定来直接与Web SDK集成,这是您的第二个选择.知道如何从Unity脚本中调用JavaScript函数可能会派上用场.

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.

这篇关于Unity WebGL构建中的Firebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆