// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } //Detecting if the player clicked on the left mouse button and also if there is no animation playing if (Input.GetButtonDown("Fire1")) { //The 3 following lines is to get the clicked GameObject and getting the RaycastHit2D that will help us know the clicked object RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.transform != null) { if ((hit.transform.gameObject.name == _TransitionRightButton.name && HOTween.GetAllTweens().Count == 0)) { GetComponent <AudioSource>().PlayOneShot(MenuSound); TransitToTheLeft(); Util.ButtonPressAnimation(_TransitionRightButton); } else if ((hit.transform.gameObject.name == _TransitionLeftButton.name && HOTween.GetAllTweens().Count == 0)) { GetComponent <AudioSource>().PlayOneShot(MenuSound); TransitToTheRight(); Util.ButtonPressAnimation(_TransitionLeftButton); } } } }
// Update is called once per frame void Update() { if (HOTween.GetAllTweens().Count == 0 && ShouldTransit) { if (_redirectedScene != string.Empty) { Application.LoadLevel(_redirectedScene); } } if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } //Detecting if the player clicked on the left mouse button and also if there is no animation playing if (Input.GetButtonDown("Fire1")) { //The 3 following lines is to get the clicked GameObject and getting the RaycastHit2D that will help us know the clicked object RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.transform != null) { if ((hit.transform.gameObject.name == this.name)) { GetComponent <AudioSource>().PlayOneShot(MenuSound); // Util.ButtonPressAnimation (hit.transform.gameObject); ShouldTransit = true; Time.timeScale = 1; } } } }