using Unity.Burst; using Unity.Entities; using Unity.Transforms; using UnityEngine; namespace HelloCube.ClosestTarget { [UpdateAfter(typeof(TargetingSystem))] [BurstCompile] public partial struct DebugLinesSystem : ISystem { [BurstCompile] public void OnCreate(ref SystemState state) { state.RequireForUpdate(); } [BurstCompile] public void OnUpdate(ref SystemState state) { foreach (var (transform, target) in SystemAPI.Query, RefRO>()) { if (SystemAPI.Exists(target.ValueRO.Value)) { var targetTransform = SystemAPI.GetComponent(target.ValueRO.Value); Debug.DrawLine(transform.ValueRO.Position, targetTransform.Position); } } } } }