EntitySerializer Class

Serializes and deserializes entities to/from JSON. Uses System.Text.Json with support for custom converters. Works automatically with ANY component type - no hardcoding needed!

public class EntitySerializer

Inheritance System.Object → EntitySerializer

Properties
Options Gets the current JSON serializer options (for advanced customization).
Methods
CopyComponentProperties(object, object) Copies all public properties from source to destination component.
CreateSnapshot(Entity) Creates a snapshot of an entity.
CreateWorldSnapshot(IEntityWorld) Creates a snapshot of the entire world.
FindComponentType(string) Finds a component type by its full name or simple name. Searches all loaded assemblies.
LoadAndRestoreWorldAsync(IEntityWorld, string, CancellationToken) Loads and restores a world from a file. CLEARS the existing world first!
LoadWorldAsync(string, CancellationToken) Loads a world snapshot from a file.
RegisterConverter(JsonConverter) Registers a custom JSON converter for a specific type. Use this to provide custom serialization for user-defined types.
RegisterConverters(JsonConverter[]) Registers multiple custom JSON converters.
RestoreComponent(Entity, string, object) Restores a component from JSON data onto an entity.
RestoreEntity(IEntityWorld, EntitySnapshot) Restores a single entity from a snapshot.
RestoreWorldFromSnapshot(IEntityWorld, WorldSnapshot) Restores entities from a snapshot into the world. CLEARS the existing world first!
SaveWorldAsync(IEntityWorld, string, CancellationToken) Saves a world snapshot to a file.