Skip to content

IDisposableComponent

Martin Evans edited this page Jul 29, 2024 · 3 revisions

A disposable component is a component defined with IDisposableComponent instead of IComponent.

public interface IDisposableComponent : IComponent
{
    public void Dispose(ref LazyCommandBuffer buffer);
}

A disposable component will automatically have Dispose called when it is destroyed. It may be destroyed by:

  • Component removed from entity
  • Entity destroyed
  • World destroyed

The LazyCommandBuffer provides access to a CommandBuffer which is lazily allocated on the first request. This allows a disposed component to queue up changes to the scene which will be automatically applied after the Dispose call. For example a Parent component could delete a child entity when it is disposed.

Clone this wiki locally