Once Data Manager is temporary data management utility kit for Unity.
Unity developer who develop the application which has multiple scenes will facing the challenge when they have to pass data between scene. So what does they do ?
Most of Unity developer prefer to use PlayerPrefs
to passing data between scene. However, there are a lot of limitation of PlayerPrefs
such as the following:
- Only
string
,float
andint
can store inPlayerPrefs
- When data are saved in
PlayerPrefs
, the system writespreference file
and save it to your storage ! (But you just only want to pass the data between scene???)
Yeah! we want to break those limitations. So we create this utility for you. Once Data Manager
will allow you to pass the data between scene with the power of DontDestroyOnload
. We create the temporary storage which you can save kind of Object on it without saving any file on your local storage!
PlayerPrefs | Once Data Manager | |
---|---|---|
Supported Data types | 3 | All |
Passing Data without saving file | No | Yes |
Number of storage | 1 | As much as you create it! |
- Download our Unity Package
- Import our package by
Assets
->Import Package
->Custom Package...
- Select
odm.unitypackage
ODM
directory will appear on your project.
- Drag
ODM Manager
inODM/Prefabs/ODM Manager.prefab
to your scene. - So now you can call
Once Data Manager Storage
to manage your data - To access
Once Data Manager
call the following code:GameObject.Find("ODM Manager").GetComponent<DataManager>().Put("Key", data); // To Add (DataTypeOfData) GameObject.Find("ODM Manager").GetComponent<DataManager>().Get("Key"); // To Get your data GameObject.Find("ODM Manager").GetComponent<DataManager>().Has("Key"); // To Check if key is existed GameObject.Find("ODM Manager").GetComponent<DataManager>().Delete("Key"); // To Delete data from Key
Note: You don't have to drag ODM Manager
to all of your scene. Just put it on the gateway scene or first scene.
Put your data to the ODM storage
Param | Data Type | Description |
---|---|---|
key | string | Key for reference to data |
data | any | Data to be store |
Get your data from the ODM storage.
Note: Please always do type casting when using this method.
Param | Data Type | Description |
---|---|---|
key | string | Key for reference to data |
Return true if key is existed in the ODM storage.
Param | Data Type | Description |
---|---|---|
key | string | Key for reference to data |
Delete data from the ODM storage.
Param | Data Type | Description |
---|---|---|
key | string | Key for reference to data |
The original purpose of this package is to saving data without writing file on user's local storage, so with ODM you can store permanent data on your local storage which can be restored when you open the application on next time like PlayerPrefs
.