using System; using System.Collections.Generic; using UnityEngine; namespace VertexColor.ScenePartition.Editor { [Serializable] public class SceneGrid { [SerializeField] private int cellSize = 10; [SerializeField] private SceneGridDictionary grid = new SceneGridDictionary(); public void Insert(uint id, Vector2 point) { Vector2 gridPos = CalculateGridPosition(point); if (grid.TryGetValue(gridPos, out List ids)) { ids.Add(id); } else { grid.Add(gridPos, new List { id }); } } public Vector2 CalculateGridPosition(Vector2 point) { int x = Mathf.FloorToInt(point.x / cellSize); int y = Mathf.FloorToInt(point.y / cellSize); return new Vector2(x, y); } } }