This page contains documentation to explain how to save and retreive user data.

This is a C# API that can be called within a mod, typically in the void OnModLoaded() on your main MonoBehaviour class. These APIs can be called at any point in time to save or retreive user data when required.

The APIs are available via AzzaMods.UserData, or simply UserData if you add the using AzzaMods; to the start of your mod like the example mod provides.


UserData.Save(string dataName, byte[] dataToSave)

This will save user data to the disk which can be retreived at a later point.

UserData.Save("save.txt", Encoding.UTF8.GetBytes("somedata"));


UserData.LoadAsync(string dataName, System.Action<string, byte[]> callback)

This will load the given user data and then fire the given action when the data finishes loading.

UserData.LoadAsync("save.txt", (string errorMessage, byte[] data) => {
    if (errorMessage == null)
        // We got data, convert to a string
        string stringData = Encoding.UTF8.GetString(data);

        // Log what we got
        Log.Info("Contents of save file is " + stringData);
        // An error occured, log what happened
        Log.Error("Failed to load savefile - " + errorMessage);