SaveUserData

public void SaveUserData(int playerId, JObject data);
public void SaveUserData(VPlayer player, JObject data);

Description

using Newtonsoft.Json.Linq;
using UnityEngine;
using Volplane;

public class Demo : VolplaneBehaviour
{
    // Save some user specific data
    public void Save(int playerId)
    {
        JObject data = new JObject();
        data.Add("aKey", "aValue");
        data.Add("hello", 27);

        SaveUserData(playerId, data);
    }
}

 

This following example shows usage in Volplane prior v1.0.3.

using SimpleJSON;
using UnityEngine;
using Volplane;

public class Demo : VolplaneBehaviour
{
    // Save some user specific data
    public void Save(int playerId)
    {
        JSONObject data = new JSONObject();
        data["aKey"] = "aValue";
        data["hello"] = 27;

        SaveUserData(playerId, data);
    }
}

This method will set a players custom user data (VPlayer.UserData). If Use Persistent Data is checked in the inspector of the Volplane Controller the data will be stored on the AirConsole servers (persistent data) and automatically loaded when this player connects to your game.

As of v1.0.3, the Volplane framework implements Newtonsofts Json.NET. You can make use of its Json to Linq feature for handling user data.

Older versions of Volplane use a modified version of SimpleJSON for handling user data.

playerId The player identifier.
player A player object.
data JSON data which should be saved (JObject / JSONObject).