Protfolio-Emanuel-Polsky / Assets / _Project / Code / PathFinding / Editor / DebugPointInGridSystem.cs
DebugPointInGridSystem.cs
Raw
using Unity.Burst;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;


namespace GarmentButton.PathFinding.Editor
{
    [BurstCompile]
    public partial struct DebugPointInGridSystem : ISystem
    {

        [BurstCompile]
        public void OnCreate(ref SystemState state)
        {
            state.RequireForUpdate<Grid>();
            state.RequireForUpdate<DebugIndex>();
        }
        [BurstCompile]
        public void OnUpdate(ref SystemState state)
        {
            var grid = SystemAPI.GetSingleton<Grid>().Value;
            var entity = SystemAPI.GetSingletonEntity<DebugIndex>();
            var index = SystemAPI.GetSingleton<DebugIndex>().Index;
            var point = grid.Value.Array[index];
            var position = new float3(point.X, point.Y, point.Z) / 10;
            Debug.Log($"Value = {index}, Position = {position}");
            Debug.DrawLine(position, position + new float3(0, 50, 0), Color.red, 50);

            state.EntityManager.DestroyEntity(entity);
        }
    }
}