Hello everyone,
I’m currently working on a project that targets both WebGL and Android platforms. For Android, I’m using Firebase for authentication and real-time database functionality. Since Firebase is not supported on WebGL, I’m trying to exclude it from the WebGL build. However, I’m encountering some issues when compiling the project for WebGL.
Here’s a snippet of my code:
#if UNITY_IOS || UNITY_ANDROID || UNITY_EDITOR
private Firebase.Auth.FirebaseAuth Auth;
private Firebase.Database.FirebaseDatabase Database;
#endif
I also tried this approach:
#if !WebGL
private Firebase.Auth.FirebaseAuth Auth;
private Firebase.Database.FirebaseDatabase Database;
#endif
While the app runs perfectly in the Unity Editor and on Android, I get the following error when I attempt to build for WebGL:
error CS0246: The type or namespace name 'Firebase' could not be found (are you missing a using directive or an assembly reference?)
It seems that Unity is still trying to reference Firebase in the WebGL build, despite my attempts to exclude it.
My question is: How can I properly exclude Firebase from the WebGL compilation to avoid this error?
Additional details:
- I’m using Unity 2022.3.48f1.
- Firebase works as expected on Android.
- I want to maintain the use of Firebase only for Android builds.
Any help or guidance on how to resolve this issue would be greatly appreciated. Thanks in advance!