forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWireframeRenderingSystem.cs
More file actions
32 lines (30 loc) · 1 KB
/
Copy pathWireframeRenderingSystem.cs
File metadata and controls
32 lines (30 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using Unity.Burst;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
namespace Graphical.PrefabInitializer
{
[WorldSystemFilter(WorldSystemFilterFlags.Default | WorldSystemFilterFlags.Editor)]
public partial struct WireframeRenderingSystem : ISystem
{
[BurstCompile]
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<ExecuteWireframeBlob>();
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
foreach (var (local, world) in
SystemAPI.Query<RefRO<WireframeLocalSpace>, DynamicBuffer<WireframeWorldSpace>>())
{
var vertices = world.Reinterpret<float3>();
ref var segments = ref local.ValueRO.Blob.Value.Segments;
for (int i = 0; i < segments.Length; i++)
{
Debug.DrawLine(vertices[segments[i].x], vertices[segments[i].y]);
}
}
}
}
}