Code inspection: DOTS: IAspect fields are required to be one of the following types: RefRW, RefRO, EnabledRefRW, EnabledRefRO, DynamicBuffer, or Entity
In Unity DOTS (Data-Oriented Technology Stack), IAspect declarations must follow specific ECS patterns for field types. This inspection ensures that fields within a struct implementing Unity.Entities.IAspect use valid accessor types.
Why is this problematic?
Fields whose type is a struct implementing IComponentData cannot be accessed directly as fields within an IAspect. They must be wrapped in specific accessor types like RefRW<T> or RefRO<T> to correctly interact with the ECS data stream. Using direct component fields will cause compilation or runtime errors in Unity's DOTS framework.
Valid accessor types
In an IAspect struct, fields must be of one of the following types:
RefRW<T>(Read-Write reference)RefRO<T>(Read-Only reference)EnabledRefRW<T>(Read-Write reference for enableable components)EnabledRefRO<T>(Read-Only reference for enableable components)DynamicBuffer<T>Entity
How to fix
Wrap the problematic field type with the appropriate accessor. JetBrains Rider provides a quick-fix to automatically wrap the field with a valid accessor. The choice between EnabledRef and Ref accessors depends on whether the component type also implements IEnableableComponent.