// Update is called once per frame void Update() { mousePos = new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y); //tracks the user mouse position #region set buttons' rectangles playButton.setRect(new Rect(Screen.width / 2 - Screen.width / 20, Screen.height / 2 - Screen.height / 7, Screen.width / 10, Screen.height / 12)); //the rectangle settings for the play button. gameModesButton.setRect(new Rect(Screen.width / 2 - Screen.width / 6.5f, Screen.height / 2 - Screen.height / 20, Screen.width / 3.2f, Screen.height / 12)); //the rectangle settings for the game modes button. optionsButton.setRect(new Rect(Screen.width / 2 - Screen.width / 11, Screen.height / 2 + Screen.height / 17, Screen.width / 5.5f, Screen.height / 12)); //the rectangle settings for the options button. creditsButton.setRect(new Rect(Screen.width / 2 - Screen.width / 12, Screen.height / 2 + Screen.height / 6, Screen.width / 6, Screen.height / 12)); //the rectangle settings for the credits button. quitButton.setRect(new Rect(Screen.width / 2 - Screen.width / 18, Screen.height / 2 + Screen.height / 3.9f, Screen.width / 9, Screen.height / 12)); //the rectangle settings for the quit button. orangeButton.setRect(new Rect(Screen.width / 2 - Screen.width / 3.6f, Screen.height / 2 - Screen.height / 3.65f, Screen.width / 16, Screen.height / 9.5f)); //the rectangle settings for the orange color button. blueButton.setRect(new Rect(Screen.width / 2 - Screen.width / 6.5f, Screen.height / 2 - Screen.height / 3.65f, Screen.width / 16, Screen.height / 9.5f)); //the rectangle settings for the blue color button. purpleButton.setRect(new Rect(Screen.width / 2 - Screen.width / 32, Screen.height / 2 - Screen.height / 3.65f, Screen.width / 16, Screen.height / 9.5f)); //the rectangle settings for the purple color button. greenButton.setRect(new Rect(Screen.width / 2 + Screen.width / 10.7f, Screen.height / 2 - Screen.height / 3.65f, Screen.width / 16, Screen.height / 9.5f)); //the rectangle settings for the green color button. pinkButton.setRect(new Rect(Screen.width / 2 + Screen.width / 4.6f, Screen.height / 2 - Screen.height / 3.65f, Screen.width / 16, Screen.height / 9.5f)); //the rectangle settings for the pink color button. onButton.setRect(new Rect(Screen.width / 2 - Screen.width / 120, Screen.height / 2 - Screen.height / 19, Screen.width / 11, Screen.height / 9.5f)); //the rectangle settings for the sound on button. offButton.setRect(new Rect(Screen.width / 2 + Screen.width / 7.8f, Screen.height / 2 - Screen.height / 19, Screen.width / 10, Screen.height / 9.5f)); //the rectangle settings for the sound off button. resetButton.setRect(new Rect(Screen.width / 2 - Screen.width / 3.7f, Screen.height / 2 + Screen.height / 7, Screen.width / 1.9f, Screen.height / 9.5f)); //the rectangle settings for the reset button. backButton.setRect(new Rect(Screen.width / 2 - Screen.width / 15, Screen.height / 2 + Screen.height / 2.85f, Screen.width / 7.5f, Screen.height / 9.5f)); //the rectangle settings for the back onbutton. tacoButton.setRect(new Rect(Screen.width / 2 - Screen.width / 2.1f, Screen.height / 2 + Screen.height / 7, Screen.width / 2.7f, Screen.height / 9.5f)); //the rectangle settings for the taco twitter button. cksnedButton.setRect(new Rect(Screen.width / 2 + Screen.width / 8.2f, Screen.height / 2 + Screen.height / 7.2f, Screen.width / 4.8f, Screen.height / 9.5f)); //the rectangle settings for the taco twitter button. #endregion #region highlight text foreach (ButtonObj navButton in navButtonSet) //for every button in the navigation button set { renderer = navButton.getGameObj().GetComponent <SpriteRenderer> (); renderer.color = navButton.getRect().Contains(mousePos) ? script.playerColor : Color.black; // if button is hovered over, set it to the player's color. Otherwise, set it to black. } if (menuRoom == 1) // if the player is in the options menu { foreach (ButtonObj colorButton in colorButtonSet) //for every pair in the color button set { renderer = colorButton.getGameObj().GetComponent <SpriteRenderer> (); colorButton.getGameObj().transform.localScale = colorButton.getRect().Contains(mousePos) ? new Vector3(1.3f, 1.3f, 1) : new Vector3(1, 1, 1); //if a button is hovered over then scale it up, otherwise make it normal size. } } SpriteRenderer renderer1 = on.GetComponent <SpriteRenderer>(); //get the sprite renderer from the on button. SpriteRenderer renderer2 = off.GetComponent <SpriteRenderer>(); //get the sprite rendered from the off button. if (script.sound) //if the sound is currently active. { renderer1.color = script.playerColor; //change the color of the on button to that of the player color. renderer2.color = Color.black; //change the color of the off button to black. } else //if the sound is currently muted. { renderer1.color = Color.black; //change the color of the on button to black. renderer2.color = script.playerColor; //change the color of the off button to that of the player color. } #endregion }