void Update() { if (active) { if (Physics.Raycast(this.transform.position, this.transform.forward, out obj, distance) && obj.collider.gameObject.tag == "Box") { guiShow = true; if (Input.GetKeyDown(key)) { boxManager = obj.collider.gameObject.GetComponent <BoxManager> (); boxManager.Open(obj.collider.gameObject); Destroy(obj.collider.gameObject); guiShow = false; } } else { guiShow = false; } } }