using GarmentButton.CameraGeneral;
using Unity.Burst;
using Unity.Entities;
namespace GarmentButton.Culling
{
public partial struct AddCameraFrustumSystem : ISystem
{
[BurstCompile]
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<EndSimulationEntityCommandBufferSystem.Singleton>();
state.RequireForUpdate<VisibleTag>();
var query = SystemAPI.QueryBuilder().WithAll<CameraReferenceProperty>().WithNone<CameraFrustumPlanes>()
.Build();
state.RequireForUpdate(query);
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
var ecbSingleton = SystemAPI.GetSingleton<EndSimulationEntityCommandBufferSystem.Singleton>()
.CreateCommandBuffer(state.WorldUnmanaged);
var cameraEntity = SystemAPI.GetSingletonEntity<CameraReferenceProperty>();
ecbSingleton.AddComponent<CameraFrustumPlanes>(cameraEntity);
}
}
}