void HighlightHoveredCell() { Rect screenRect = new Rect(0, 0, Screen.width, Screen.height); if (!screenRect.Contains(Input.mousePosition)) { return; } Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(inputRay, out hit, Mathf.Infinity, 1 << LayerMask.NameToLayer("Chunks"))) { HexChunk chunk = hit.collider.gameObject.GetComponent <HexChunk>(); HexCell cell = chunk.subtestCollision(inputRay); if (cell != null) { cell.setHighlighted(); if (chunk != highlightedChunk) { highlightedChunk.RerenderCells(); highlightedChunk = chunk; } Debug.Log(cell.name); chunk.RerenderCells(); } } }
void HandleInput() { Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(inputRay, out hit, Mathf.Infinity, 1 << LayerMask.NameToLayer("Chunks"))) { Debug.Log(hit.collider.gameObject.name); HexChunk chunk = hit.collider.gameObject.GetComponent <HexChunk>(); HexCell cell = chunk.subtestCollision(inputRay); if (cell != null) { cell.recursivelyAdjustHeight(20, 5, 1); chunk.RerenderCells(); } } }