Data Model

Like what your seeing?

Consider supporting us as a GitHub Sponsor and get instant access to all our Unity assets, exclusive tools and assets, escalated support and issue tracking and our gratitude. These articles are made possible by our GitHub Sponsors ... become a sponsor today!


public class DataModel<T>: DataModel
public class DataModel : ScriptableObject
It is intended that you use this to create your core save files as Scriptable Objects. This makes it trivial to query the Steam Remote Storage interface for records of this file type and to load data into a usable point in memory that can easily be referenced by Unity components.
You would typically start by defining your underlying data type e.g. a serializable object that represents the data you wish to save
public class MyCharacterData
public string characterName;
public int level;
public float3 position;
public quaternion rotation;
//... etc.
You would then create your DataModel
[CreateAssetMenu(menuName = "My Objects/Character Data Model")]
public class CharacterDataModel : DataModel<MyCharacterData>
{ }
You do not need to write any code in the body of the DataModel, the base class will implament everything you need for you.
Once complete you can use your new ScriptableObject to represent the currently loaded copy of this data type and you can use its member funcitons to list the available files of this type as seen on Steam Remote Storage and to read and write given files.

Fields and Attributes

The extension to be used with this model
List of available files found on Steam Remote Storage
The underlying data type used by this model
The data stored by this model



public void Refresh();
Reads the list of available files from the remote storage interface and stores them in the availabelFiles collection

Load Data

public void LoadByteArray(data);
public void LoadJson(data);
public void LoadFileAddress(address);
Manually loads data into the model's data field

Export Data

public byte[] ToByteArray();
Outputs the current data as a byte[]
public string ToJson();
Outputs the current data as a JSON string

Save Data

public void Save(fileName);
Saves the current data to the Steam Remote Storage system with the indicated file name