void Update() { if (!isOn) { return; } if (Input.GetMouseButton(0)) { panel.SetActive(true); Vector3 mousePos = Input.mousePosition; Ray mouseRay = cam.ScreenPointToRay(mousePos); RaycastHit[] hits = Physics.RaycastAll(mouseRay); for (int i = 0; i < hits.Length; i++) { RaycastHit hit = hits [i]; if (hit.transform.gameObject.name == "draggerPlane") { trailObject.transform.position = hit.point; if (addParticle) { particles.SetOn(fruitType, hit.point); addParticle = false; } } } } else if (Input.GetMouseButtonUp(0)) { panel.SetActive(false); } }