Game.ModificationBarrier5
Assembly:
Assembly-CSharp.dll (inferred — game runtime assembly where Game.* types are usually defined)
Namespace: Game.Common
Type: public class
Base: SafeCommandBufferSystem
Summary: ModificationBarrier5 is a lightweight barrier system derived from SafeCommandBufferSystem. It exists to provide a well-ordered point in the frame where recorded modification command buffers can be played back/committed. The class itself does not add custom update logic; it overrides OnUpdate and delegates directly to the base implementation. The class and its members are annotated with Preserve attributes and the OnUpdate override is marked NoInlining to avoid stripping and inlining by the runtime/compiler, ensuring correct registration and ordering in the game/mod runtime. The "5" in the name suggests this is one of several indexed modification barriers used for ordering.
Fields
- This class declares no instance or static fields.
Properties
- This class declares no additional properties beyond those inherited from its base types.
Constructors
public ModificationBarrier5()
This default constructor is decorated with [Preserve], which prevents the Unity linker from stripping the type/ctor when building the game/mod. The ctor performs no custom initialization and relies on the base class and Unity's system registration.
Methods
protected override void OnUpdate() : System.Void
This method is marked with [Preserve] and [MethodImpl(MethodImplOptions.NoInlining)]. Its implementation simply calls base.OnUpdate()
. The attributes ensure the method is preserved from stripping and not inlined, which helps maintain explicit update ordering and runtime behavior expected by the mod/game.
Usage Example
using Unity.Entities;
using UnityEngine.Scripting;
public partial class MyModificationProducerSystem : SystemBase
{
protected override void OnUpdate()
{
// Retrieve the modification barrier system from the active World.
// Depending on your DOTS/Entities version you may use GetExistingSystemManaged/GetOrCreateSystemManaged or similar.
var barrier = World.DefaultGameObjectInjectionWorld.GetExistingSystemManaged<Game.Common.ModificationBarrier5>();
if (barrier != null)
{
// Create a command buffer from the barrier and record modifications.
var ecb = barrier.CreateCommandBuffer();
// ... record entity/component changes onto ecb ...
}
// Note: ModificationBarrier5 doesn't add extra logic on top of the base SafeCommandBufferSystem;
// it's generally used only to control ordering and to obtain command buffers at a specific barrier point.
}
}
Notes:
- The class is intentionally minimal; its main role is ordering/registration as a dedicated modification barrier.
- Keep the [Preserve] usage if you need this system to remain available in builds where code stripping is enabled.