private void UseMousePos(Vector3 inputPos) { //Needed to cast rays for collision detection in perspective mode Vector3 touchPosFar = new Vector3(inputPos.x, inputPos.y, Camera.main.farClipPlane); Vector3 touchPosNear = new Vector3(inputPos.x, inputPos.y, Camera.main.nearClipPlane); //Needed to cast rays for collision detection in perspective mode Vector3 touchPosF = Camera.main.ScreenToWorldPoint(touchPosFar); Vector3 touchPosN = Camera.main.ScreenToWorldPoint(touchPosNear); //User clicks on lever during play RaycastHit2D hit = Physics2D.Raycast(touchPosN, touchPosF - touchPosN); if (hit.collider != null) { Lever _lever = hit.collider.GetComponent <Lever>(); if (_lever != null) { _lever.LeverGetsClicked(); } } //User clicks on Credits button in start menu if (hit.collider != null && hit.collider.name == ("CreditsButton")) { StartScreenManager startScreen = transform.GetComponent <StartScreenManager>(); startScreen.CreditsClick(); } //User clicks on back button in credits if (hit.collider != null && hit.collider.name == ("BackButton")) { StartScreenManager startScreen = transform.GetComponent <StartScreenManager>(); startScreen.BackCreditsClick(); } //User clicks on play button in start menu if (hit.collider != null && hit.collider.name == ("StartGameButton")) { SceneSwitcher sceneSwitcher = transform.root.GetComponent <SceneSwitcher>(); sceneSwitcher.LoadNextScene(); } //User clicks on exit button in start menu if (hit.collider != null && hit.collider.name == ("ExitButton")) { SceneSwitcher sceneSwitcher = transform.root.GetComponent <SceneSwitcher>(); sceneSwitcher.ExitGame(); } }