Skip to content

Repository files navigation

GameLovers GameData

Unity VersionLicense: MITVersion

Quick Links: Installation | Features | Editor Tools | Contributing

Why Use This Package?

Managing game data in Unity often leads to fragmented solutions: scattered config files, tight coupling between data and logic, and cross-platform inconsistencies. This GameData package addresses these challenges:

ProblemSolution
Scattered config managementType-safe ConfigsProvider with O(1) lookups and versioning
Tight coupling to data changesObservable types (ObservableField, ObservableList, ObservableDictionary) for reactive programming
Manual derived state updatesComputedField for auto-updating calculated values with dependency tracking
Cross-platform float inconsistenciesDeterministic floatP type for reproducible calculations across all platforms
Backend sync complexityBuilt-in JSON serialization with ConfigsSerializer for client/server sync
Dictionary Inspector editingUnitySerializedDictionary for seamless Inspector support
Fragile enum serializationEnumSelector stores enum names (not values) to survive enum changes

Built for production: Minimal dependencies. Zero per-frame allocations in observable types. Used in real games.


System Requirements

  • Unity 6000.0+ (Unity 6)
  • Newtonsoft.Json (com.unity.nuget.newtonsoft-json v3.2.1) — automatically resolved
  • TextMeshPro (com.unity.textmeshpro v3.0.6) — used by Samples~ UI scripts only
Unity VersionStatus
6000.0+ (Unity 6)✅ Fully Tested
2022.3 LTS⚠️ Untested

Installation

Via Unity Package Manager (Recommended)

  1. Open Unity Package Manager (WindowPackage Manager)
  2. Click +Add package from git URL
  3. Enter: https://github.com/CoderGamester/com.gamelovers.gamedata.git

Via manifest.json

{
"dependencies": {
"com.gamelovers.gamedata": "https://github.com/CoderGamester/com.gamelovers.gamedata.git"
}
}

Key Components

ComponentResponsibility
ConfigsProviderType-safe config storage with O(1) lookups and versioning
ConfigsSerializerJSON serialization for client/server config synchronization
ConfigTypesBinderWhitelist-based type binder for secure deserialization
ObservableFieldReactive wrapper for single values with change callbacks
ObservableListReactive wrapper for lists with add/remove/update callbacks
ObservableDictionaryReactive wrapper for dictionaries with key-based callbacks
ComputedFieldAuto-updating derived values that track dependencies
floatPDeterministic floating-point type for cross-platform math
MathfloatPMath functions (Sin, Cos, Sqrt, etc.) for floatP
EnumSelectorEnum dropdown that survives enum value changes
UnitySerializedDictionaryDictionary type visible in Unity Inspector

Editor Tools

ToolMenuPurpose
Config BrowserTools > Game Data > Config BrowserBrowse configs, validate, export JSON, preview migrations
Observable DebuggerTools > Game Data > Observable DebuggerInspect live observables in play mode
ConfigsScriptableObject InspectorInspector (automatic)Inline duplicate-key validation and Validate All action

Features Documentation

ConfigsProvider

Type-safe, high-performance configuration storage.

varprovider=newConfigsProvider();provider.AddConfigs(item =>item.Id,itemConfigs);provider.AddSingletonConfig(newGameSettings{Difficulty=2});varitem=provider.GetConfig<ItemConfig>(42);varsettings=provider.GetConfig<GameSettings>();// Zero-allocation enumerationforeach(varenemyinprovider.EnumerateConfigs<EnemyConfig>())ProcessEnemy(enemy);

ConfigsSerializer

JSON serialization with security modes.

varserializer=newConfigsSerializer();// TrustedOnly by defaultstringjson=serializer.Serialize(provider,"123");varrestored=serializer.Deserialize<ConfigsProvider>(json);serializer.RegisterAllowedTypes(new[]{typeof(EnemyConfig)});

ObservableField

varscore=newObservableField<int>(0);score.Observe((prev,curr)=>UpdateScoreUI(curr));score.InvokeObserve((prev,curr)=>UpdateScoreUI(curr));// invokes immediately tooscore.Value=100;score.StopObservingAll(this);

ComputedField

varbaseHp=newObservableField<int>(100);varbonus=newObservableField<int>(25);vartotalHp=newComputedField<int>(()=>baseHp.Value+bonus.Value);totalHp.Observe((prev,curr)=>Debug.Log($"HP: {curr}"));baseHp.Value=120;// totalHp auto-updates to 145totalHp.Dispose();

ObservableList / ObservableDictionary

varinventory=newObservableList<string>(newList<string>());inventory.Observe((index,prev,curr,type)=>RefreshUI(index,curr));inventory.Add("Sword");varstats=newObservableDictionary<string,int>(newDictionary<string,int>());stats.Observe("health",(key,prev,curr,type)=>Debug.Log($"{key}: {curr}"));stats.Add("health",100);

Deterministic floatP

floatPa=3.14f;floatPsum=a+2.0f;floatresult=(float)sum;uintraw=a.RawValue;// bit-exact for determinismfloatPcopy=floatP.FromRaw(raw);

UnitySerializedDictionary / EnumSelector

[Serializable]publicclassStringIntDictionary:UnitySerializedDictionary<string,int>{}[Serializable]publicclassItemTypeSelector:EnumSelector<ItemType>{publicItemTypeSelector():base(ItemType.Weapon){}}// ItemType type = selector; — implicit conversion// bool ok = selector.HasValidSelection();

Samples

Import via Package Manager → GameLovers GameData → Samples

SampleDemonstrates
Reactive UI DemoObservableField, ObservableList, ComputedField, batched updates — uGUI and UI Toolkit
Designer WorkflowConfigsScriptableObject, UnitySerializedDictionary, EnumSelector with PropertyDrawer
MigrationIConfigMigration, MigrationRunner, Config Browser migration workflow

Contributing

Contributions are welcome! Report bugs or request features via GitHub Issues. For development setup, architecture, coding standards, and test placement, see AGENTS.md.


Related docs

DocumentPurpose
AGENTS.mdContributor/agent guide (architecture, gotchas, workflows)
CHANGELOG.mdVersion history

Support

License

MIT — see LICENSE.md.

About

This package extends various sets of data types to be used in any type of data containers or persistent serializable data

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages