Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wolf-org/game-data-unity
System game data unity (Unity 2022.3)
https://github.com/wolf-org/game-data-unity
backup-data game-data gamedata gamedata-unity restore-data unity unity3d
Last synced: about 23 hours ago
JSON representation
System game data unity (Unity 2022.3)
- Host: GitHub
- URL: https://github.com/wolf-org/game-data-unity
- Owner: wolf-org
- License: mit
- Created: 2024-06-28T09:30:44.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-10-24T09:48:49.000Z (27 days ago)
- Last Synced: 2024-10-25T07:37:08.951Z (26 days ago)
- Topics: backup-data, game-data, gamedata, gamedata-unity, restore-data, unity, unity3d
- Language: C#
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## What
```mermaid
flowchart LR
Unity.Serialization{Unity.Serialization} --> W(Write) & R(Read)
click Unity.Serialization "https://docs.unity3d.com/Packages/[email protected]/manual/index.html" _blank
Data[("Data
Profile 0
.
.
.
Profile N
Dictionary<string,byte[]>")] --> |Default use profile 0| ChangeProfile(ChangeProfile)
Data --> |Save on Application pause or quit| SaveToFile(SaveToFile)--> Unity.Serialization
Data --> |Load when startup| LoadFromFile(LoadFromFile)--> Unity.Serialization
Data --> Get(Get<T>) & Set(Set<T>) & DeleteKey(DeleteKey) & HasKey(HasKey) & DeleteAll(DeleteAll)
File{{File Data}} --- W & R
```- System data for game unity (Unity 2022.3)
- Using [Unity.Serialization](https://docs.unity3d.com/Packages/[email protected]/manual/index.html) to serialize binary data
- Data allows you to store data in byte[] form in blocks called profiles. Each profile is a Dictionary with the key as a string and the value
## How To Install
### Add the line below to `Packages/manifest.json`for version `1.0.2`
```csharp
"com.wolf-org.game-data":"https://github.com/wolf-org/game-data-unity.git#1.0.2",
```
## Use- Initialize data when loading the game: `GameData.Init()` Data will be init (Load Data) automatically when game starts
- Change Profile: `GameData.ChangeProfile(int profile)`
- Load Data: `GameData.Load()` Load all data from file for game
- Get Data: `GameData.Get("KEY", valueDefault);` Use similar to PlayerPrefs
- Set Data: `GameData.Set("KEY", value);` Use similar to PlayerPrefs
- Save Data: `GameData.Save()` Save data to file (You should save when pausing or quitting the game)
```csharp
private void OnApplicationPause(bool pauseStatus)
{
if(pauseStatus) GameData.Save();
}
```
- Has Key: `GameData.HasKey(string key)` To check if the profile has a key,
- DeleteKey: `GameData.DeleteKey(string key)` To delete the key from the profile
- DeleteAll: `GameData.DeleteAll()` To delete the entire key
- Backup: `GameData.Backup()` Get raw byte[] of all data of profile
- Restore: `GameData.Restore(byte[] bytes)` Load from byte[]