Firebase Cloud Saving (BETA)

Crystal Save supports Firebase Cloud Storage as a backend for storing save slot files and metadata. This allows your game to upload and retrieve save data from Firebase, enabling cross-device persistence and cloud backups.


1. Enabling Firebase Cloud Save

You can configure Firebase integration either through:

  • SaveSettings asset (Create → Crystal Save → Settings → Create Save Settings File)

  • RememberMeSettingsWindow in the Unity Editor

Steps

  • Open SaveSettings

  • Enable Cloud Save by setting:

    settings.enableCloudSave = true;
  • Set the Save Backend to Firebase:

settings.backend = SaveBackend.Firebase;
  • Provide your Firebase bucket name and authentication token:

settings.firebaseBucket = "my-app.appspot.com";
settings.firebaseIdToken = "<FIREBASE_ID_TOKEN>";

firebaseBucket → Found in your Firebase Console → Storage → Bucket URL.

firebaseIdToken → Retrieved from Firebase Authentication after the user logs in.

  • Choose a User Folder Strategy:

settings.userFolderStrategy = UserFolderStrategy.UnityAuthentication;

Options include:

  • Shared – all users share the same folder.

  • UnityAuthentication – per Unity Services user.

  • GuidPerDevice – unique folder per device.

  • Custom – use your own IUserFolderResolver implementation.


2. Typical Configuration Example

var settings = ScriptableObject.CreateInstance<SaveSettings>();
settings.enableCloudSave        = true;
settings.backend                = SaveBackend.Firebase;
settings.firebaseBucket         = "my-app.appspot.com";
settings.firebaseIdToken        = "<FIREBASE_ID_TOKEN>";
settings.userFolderStrategy     = UserFolderStrategy.UnityAuthentication;

3. Runtime Usage

When Firebase is selected as the backend, Crystal Save automatically uses FirebaseSaveSystem internally.

Saving to Firebase

await SaveManager.Instance.SaveAsync(slotNumber);

Loading from Firebase

await SaveManager.Instance.LoadSaveSlotAsync(slotNumber);

4. What Gets Uploaded

For each save slot:

  • Data file: slot-{N}.sav

  • Metadata file: slot-{N}.json

  • If keepLocalMirror is enabled, these files are also saved to:

    Application.persistentDataPath

5. Firebase Integration Flow

Tips & Notes

  • Ensure your Firebase Storage rules allow read/write access for authenticated users.

  • If using Custom User Folder Strategy, your resolver must implement IUserFolderResolver and return the correct folder path for each user.

  • The Firebase ID Token should be refreshed periodically if it has an expiry time.

  • Works across all platforms that can send HTTP requests (including WebGL).

Last updated