void FixedUpdate() { Ray ray; if (defaultMode) { ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.4f, 0f)); } else { if (!Camera.current) return; ray = Camera.current.ScreenPointToRay(Input.mousePosition); } RaycastHit hit; if (Physics.Raycast(ray, out hit, 1.9f)) { var newCell = hit.collider.gameObject.GetComponent<PhysicalCell>(); if (newCell != null) { if (cell != null) cell.OnLookAway(); newCell.OnLookAt(); cell = newCell; } transform.position = new Vector3(hit.point.x, hit.point.y + 0.002f, hit.point.z); } else { transform.position = Vector3.zero; } }
public PhysicalCell[] GetAllPhysicalCells() { PhysicalCell[] all = new PhysicalCell[pcells.Count]; pcells.Values.CopyTo(all, 0); return all; }