Skip to main content
File: Packages/com.molca.core/Runtime/Networking/Data/DataManager.cs

When to use

Use DataManager instead of one-off HttpClient calls when you need:
  • Persistent data providers that continuously feed data (HTTP polling, SSE, WebSocket patterns).
  • Centralized caching with configurable duration and max size per provider.
  • Model subscriptions — get notified when new data arrives for a specific DataModel, with automatic batching to reduce callback frequency.
  • Multiple data sources coordinated through a single gateway with provider registration/deregistration.
For simple one-shot API calls, prefer HttpClient directly.

API

Provider management

Data subscription and access

Events: OnDataUpdated, OnDataProviderRegistered, OnDataProviderUnregistered (static event Action).

Code

Subscribe to model updates (recommended for live data):
Event-based (for generic data change notifications):
Resolve the subsystem: DataManager.Instance (RuntimeManager.GetSubsystem<DataManager>()).

API Reference

Cache and data pool management

Utility methods

Troubleshooting

  • Subscribed but no callbacks firing: verify the DataModel.ModelId matches between the provider’s mapping and your subscription. Enable DataConfig.LogDataOperations to see subscription/flush logs.
  • Data arrives but view is stale: DataManager batches data into pools flushed every ~100ms. Call FlushAllDataPools() if you need immediate processing. Also confirm you’re subscribing to the correct DataModel instance.
  • Provider not found: RegisterDataProvider must be called before FetchData. Check that the provider’s ProviderId matches and the mapping / DataModel is assigned.
  • Cache grows unbounded: configure DefaultMaxCacheSize and DefaultCacheDuration on the DataConfig module in Global Settings.

Unity Editor

Data Manager Inspector

DataManager module configuration