-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHexMapEditor.cs
More file actions
40 lines (32 loc) · 804 Bytes
/
HexMapEditor.cs
File metadata and controls
40 lines (32 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using UnityEngine;
using UnityEngine.EventSystems;
public class HexMapEditor : MonoBehaviour
{
public Color[] colors;
public HexGrid hexGrid;
private Color activeColor;
private void Awake()
{
SelectColor(0);
}
void Update()
{
if (Input.GetMouseButton(0) && !EventSystem.current.IsPointerOverGameObject())
{
HandleInput();
}
}
void HandleInput()
{
Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(inputRay, out hit))
{
hexGrid.ColorCell(hit.point, activeColor);
}
}
public void SelectColor (int index)
{
activeColor = colors[index];
}
}