Protfolio-Emanuel-Polsky / Assets / _Project / Code / PathFinding / Editor / DebugPointWindow.cs
DebugPointWindow.cs
Raw
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.Entities;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;

namespace GarmentButton.PathFinding.Editor
{
    public class DebugPointWindow : EditorWindow
    {
        private int _index;

        [MenuItem("Tools /PathFinding /DebugPath Runtime")]
        public static void ShowWindow()
        {
            GetWindow<DebugPointWindow>("DebugPath Point");
        }
        private void CreateGUI()
        {
            var intField = new IntegerField();
            intField.label = "Index";
            intField.RegisterValueChangedCallback((evt) =>
            {
                _index = (int)evt.newValue;
            });
            var button = new Button(DebugIndexs);
            button.text = "DebugPath";

            rootVisualElement.Add(intField);
            rootVisualElement.Add(button);
        }

        private void DebugIndexs()
        {
            var entityManger = World.DefaultGameObjectInjectionWorld.EntityManager;
            var entity = entityManger.CreateEntity();
            entityManger.AddComponentData(entity, new DebugIndex
            {
                Index = _index
            });
        }
    }
}