文档

Unity Engine

Unity Engine

LastSystemVersion

The current version of this system.
阅读时间1 分钟最后更新于 19 天前

Definition

  • Type: Property
  • Namespace: Unity.Entities
  • Assembly: UnityEngine.EntitiesModule
public uint LastSystemVersion { get; }

Remarks

LastSystemVersion is updated to match the SystemState.GlobalSystemVersion whenever a system runs.
When you use EntityQuery.SetChangedVersionFilter or ArchetypeChunk.DidChange, LastSystemVersion provides the basis for determining whether a component could have changed since the last time the system ran.
When a system accesses a component and has write permission, it updates the change version of that component type to the current value of LastSystemVersion. The system updates the component type's version whether or not it actually modifies data in any instances of the component type -- this is one reason why you should specify read-only access to components whenever possible.
For efficiency, ECS tracks the change version of component types by chunks, not by individual entities. If a system updates the component of a given type for any entity in a chunk, then ECS assumes that the components of all entities in that chunk could have been changed. Change filtering allows you to save processing time by skipping all entities in an unchanged chunk, but does not support skipping individual entities in a chunk that does contain changes.