GridTest.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using KairoEngine.Grids;
  5. using KairoEngine.Utility;
  6. public class GridTest : MonoBehaviour
  7. {
  8. public bool debugGrid = false;
  9. public Vector2Int gridSize;
  10. public float cellSize = 10f;
  11. public GridPlane gridPlane = GridPlane.XY;
  12. public Vector3 gridPosition = new Vector3();
  13. private Grid<HeatMapGridObject> grid;
  14. [SerializeField] private HeatMapVisual heatMapVisual;
  15. void Start()
  16. {
  17. grid = new Grid<HeatMapGridObject>(gridSize.x, gridSize.y, cellSize, gridPosition, (Grid<HeatMapGridObject> g, int x, int y) => new HeatMapGridObject(g, x, y),
  18. gridPlane, debugGrid);
  19. heatMapVisual.SetGrid(grid);
  20. }
  21. private void Update()
  22. {
  23. if(Input.GetMouseButtonDown(0))
  24. {
  25. Vector3 mousePos = Utilities.GetMouseWorldPosition();
  26. //int value = grid.GetValue(mousePos);
  27. //value += 10;
  28. //value = Mathf.Clamp(value, HeatMapVisual.HEAT_MAP_MIN_VALUE, HeatMapVisual.HEAT_MAP_MAX_VALUE);
  29. //grid.SetValue(Utilities.GetMouseWorldPosition(), value);
  30. heatMapVisual.AddValue(mousePos, 100, 0, 5);
  31. }
  32. if(Input.GetMouseButtonDown(1))
  33. {
  34. Debug.Log(grid.GetObject(Utilities.GetMouseWorldPosition()));
  35. }
  36. }
  37. }