Game.Prefabs.SaveInstance
Assembly:
Game (may be part of Assembly-CSharp or Game assembly in the built project)
Namespace: Game.Prefabs
Type:
struct
Base:
System.ValueType
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary:
SaveInstance is an empty "tag" component used with Unity's ECS (Entities) to mark entities as save/load instances for prefab handling. The type is annotated with [StructLayout(LayoutKind.Sequential, Size = 1)] to force a defined, minimal memory footprint (1 byte), ensuring a stable memory layout and avoiding zero-sized type representation. Implementing IQueryTypeParameter makes the type usable directly in query builder APIs (e.g., WithAll
Fields
- This type declares no fields.
SaveInstance is an empty/tag component; the StructLayout attribute ensures it occupies 1 byte in memory to make it suitable for storage as a component even though it carries no data.
Properties
- This type declares no properties.
It is used purely as a marker/tag in entity component queries and component lists.
Constructors
public SaveInstance()
Structs get a default, zero-initialized value. You can create an instance vianew SaveInstance()
when adding the component to an entity, but there are no custom constructors or data to initialize.
Methods
- This type declares no methods.
Usage consists of adding/removing the component on entities and using it in queries as a marker.
Usage Example
// Add the tag to an entity (EntityManager API)
entityManager.AddComponentData(entity, new SaveInstance());
// Remove the tag
entityManager.RemoveComponent<SaveInstance>(entity);
// Query for entities that are marked as SaveInstance
Entities.WithAll<SaveInstance>().ForEach((Entity e) =>
{
// Process entities that were marked as save instances
}).Schedule();
// Using EntityQueryBuilder-style usage
var query = SystemAPI.QueryBuilder().WithAll<SaveInstance>().Build();
Notes: - Use SaveInstance to mark entities that should be treated specially when saving/loading prefabs or when filtering systems that operate only on saved prefab instances. - Because the component contains no payload data, behavior is expressed in systems that query for the presence (or absence) of this component.