Work State Serialization

- Worked on serialization issues (some string data doesn't get correctly formatted, but was also not needed, so removed the data part from ScenePartition)
- Moved some files to runtime (wip)
This commit is contained in:
max
2023-06-26 01:03:14 +02:00
parent 3bba6da1a6
commit b6f9052cff
12 changed files with 169 additions and 101 deletions

37
Runtime/SceneGrid.cs Normal file
View File

@ -0,0 +1,37 @@
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<uint> ids))
{
ids.Add(id);
}
else
{
grid.Add(gridPos, new List<uint> { 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);
}
}
}