{"id":13784359,"url":"https://github.com/JimmyCushnie/PersistentData","last_synced_at":"2025-05-11T19:32:49.231Z","repository":{"id":101316730,"uuid":"232716170","full_name":"JimmyCushnie/PersistentData","owner":"JimmyCushnie","description":"Easy cross-platform data saving and loading for Unity","archived":false,"fork":false,"pushed_at":"2022-04-06T10:46:10.000Z","size":24,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-10T11:12:08.450Z","etag":null,"topics":["configuration-files","playerprefs","serialization","succ","unity","unity3d"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JimmyCushnie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-01-09T03:43:19.000Z","updated_at":"2024-10-15T19:25:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"a99d7652-ef79-45ed-bc2b-89a80f568215","html_url":"https://github.com/JimmyCushnie/PersistentData","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JimmyCushnie%2FPersistentData","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JimmyCushnie%2FPersistentData/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JimmyCushnie%2FPersistentData/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JimmyCushnie%2FPersistentData/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JimmyCushnie","download_url":"https://codeload.github.com/JimmyCushnie/PersistentData/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225086608,"owners_count":17418763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration-files","playerprefs","serialization","succ","unity","unity3d"],"created_at":"2024-08-03T19:00:41.013Z","updated_at":"2024-11-17T20:31:50.431Z","avatar_url":"https://github.com/JimmyCushnie.png","language":"C#","funding_links":[],"categories":["Code"],"sub_categories":[],"readme":"# PersistentData\nEasy cross-platform data saving and loading for Unity\n\n### The Problem\n\nI like to make [games](https://itch.io/c/331409/game-jam-games) that work both on desktop and in WebGL.\n\nMy games usually need to save data of some kind, like user settings or highscores. On desktop, I like to use [SUCC](https://github.com/JimmyCushnie/SUCC), because it generates files in a convenient location and formatted in a beautiful way.\n\nHowever, SUCC doesn't work in WebGL, so my cross-platform games can't use it.\n\n### The Solution\n\nPersistentData is a clean API for saving c# data. On desktop platforms, the data is saved as [SUCC](https://github.com/JimmyCushnie/SUCC). On all other platforms, the data is serialized with [Newtonsoft.Json](https://docs.unity3d.com/Packages/com.unity.nuget.newtonsoft-json@3.0/manual/index.html), then stored in [PlayerPrefs](https://docs.unity3d.com/ScriptReference/PlayerPrefs.html).\n\nThis means the desktop versions of your apps will have beautiful convenient SUCC data files, but your apps will still work perfectly on other platforms without you needing to write any platform-dependent code.\n\n## Installing\n\n1. Install [SUCC](https://github.com/JimmyCushnie/SUCC) via the package manager (Add package from git URL -\u003e `https://github.com/JimmyCushnie/SUCC.git#unity`)\n2. Install [Newtonsoft.Json](https://docs.unity3d.com/Packages/com.unity.nuget.newtonsoft-json@3.0/manual/index.html) via the package manager (Add package by name -\u003e `com.unity.nuget.newtonsoft-json`)\n3. Install PersistentData via the package manager (Add package from git URL -\u003e `https://github.com/JimmyCushnie/PersistentData.git`)\n\n## Usage\n\nAll of the functions from this library are in the `PersistentData.GameValues` class. They all have xml documentation.\n\nPersistentData's API is very similar to [SUCC's DataFile API](https://github.com/JimmyCushnie/SUCC/wiki/Getting-Started#get-and-set-values-in-the-file).\n\n### Example\n\n```csharp\nusing PersistentData;\n...\n\nconst string KEY_HIGHSCORE = \"highscore\";\n\nvoid SaveHighscore(int score) \n    =\u003e GameValues.Set(KEY_HIGHSCORE, score);\n\nint LoadHighscore() \n    =\u003e GameValues.Get(KEY_HIGHSCORE, defaultValue: 0);\n```\n\n### Notes on complex type serialization\n\nWhen you're serializing a [Complex Type](https://github.com/JimmyCushnie/SUCC/wiki/Complex-Types), both the desktop and non-desktop serializers use attributes to determine what to serialize.\n\nDesktop (SUCC):\n\n* public fields and properties are serialized unless marked with the `[SUCC.DontSaveThis]` attribute\n* private fields and properties are serialized if and only if marked with the `[SUCC.SaveThis]` attribute\n\nWebGL/other (Newtonsoft.Json):\n\n* public fields and properties are serialized unless marked with the `[Newtonsoft.Json.JsonIgnore]` attribute\n* private fields and properties are serialized if and only if marked with the `[Newtonsoft.Json.JsonProperty]` attribute\n\nIn order to keep serialization consistent between platforms, it is recommended that you only save complex types without any of the above attributes on any members.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJimmyCushnie%2FPersistentData","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJimmyCushnie%2FPersistentData","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJimmyCushnie%2FPersistentData/lists"}