Naive implementation of the most popular Firebase modules for Web apps and games made by Unity Engine.
Google does not provide support for the Unity WebGL plugin, so I've decided to do it by myself.
- An easy-to-setup via one Firebase settings file, no additional actions required!
- An easy-to-use API similar to the official Firebase plugin for Unity (iOS/Android) with small differences.
- App
- App-Check (limitations: no support for Custom Providers, ReCAPTCHA v3 and ReCAPTCHA Enterprise only)
- Auth (limitations: no support for persistence and resolvers)
- Analytics
- Functions
- Installations
- Messaging (limitations: no support for Service Worker 'onBackgroundMessage')
- Performance
- Remote Config
- Storage
As I see the situation, next modules are not used very often in games (for hypercasual/casual games it doesn't needed at all, for midcore/hardcode games usually used self-hosted backends)
- AI
- Database
- Firestore
If I wrong, feel free to ping me and I will add these modules in the package as soon as possible.
- [Runtime] Just few
*.csand*.jslibfiles - [Editor]
HtmlAgilityPack.dllas a dependency
The latest version can be installed via package manager using following git URL:
https://github.com/am1goo/FirebaseWebGL-Unity.git#0.9.5
- UniTask extensions package: com.am1goo.firebase.webgl.unitask
private FirebaseWebGL.FirebaseApp app;
void Awake()
{
app = FirebaseWebGL.FirebaseApp.DefaultInstance();
}IEnumerator Start()
{
if (app.Analytics != null)
{
bool? isInitialized;
app.Analytics.Initialize((callback) =>
{
if (callback.success == false)
{
Debug.LogError($"Initialize: {callback.error}");
yield break;
}
isInitialized = callback.result;
});
yield return new WaitUntil(() => initialized != null);
Debug.Log($"Initialized: {isInitialized}");
}
}...
app.Analytics.LogEvent("my event");
...You will probably experience difficulties loading additional scripts from Google servers. To resolve, ask your IT or web-platform support to add following domains to CORS policies:
fcmregistrations.googleapis.com
firebase.googleapis.com
firebaseappcheck.googleapis.com
firebaseinstallations.googleapis.com
firebaselogging.googleapis.com
firebaseremoteconfig.googleapis.com
firebasestorage.googleapis.com
firebasevertexai.googleapis.com
firestore.googleapis.com
identitytoolkit.googleapis.com
By default, to use Firebase functionality, the settings file should be located at specified path Resources/FirebaseSettings.asset.
If you want to override this behaviour, you may define FIREBASE_WEBGL_SETTINGS_PATH environment argument during the build process.
It can be useful in case where you want to have different configurations for various web platforms (Crazy Games, Poki, Playhop and others).
- Unity 2020.3.x
Contribution in any form is very welcome. Bugs, feature requests or feedback can be reported in form of Issues.