void SetTilt(bool value) { if (value) { TiltButton.GetComponent <SpriteRenderer> ().sprite = tiltOff; } else { TiltButton.GetComponent <SpriteRenderer> ().sprite = tiltOn; } }
// Use this for initialization void Start() { playerName = PlayerPrefs.GetString("PlayerName"); if (playerName == "") { playerName = "PlayerName"; } mute = PlayerPrefs.GetInt("Mute") == 1 ? true : false; tilt = PlayerPrefs.GetInt("Tilt") == 1 ? true : false; if (tilt) { TiltButton.GetComponent <SpriteRenderer> ().sprite = tiltOn; } else { TiltButton.GetComponent <SpriteRenderer> ().sprite = tiltOff; } if (mute) { OnOffButton.GetComponent <SpriteRenderer> ().sprite = on; AudioListener.pause = true; } else { OnOffButton.GetComponent <SpriteRenderer> ().sprite = off; AudioListener.pause = false; } if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsWebPlayer) { TiltButton.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 0.3f); tiltButtonEnabled = false; } hostOn.SetActive(false); joinOn.SetActive(false); NameButton.SetActive(false); TiltButton.SetActive(false); BackButton.SetActive(false); MuteButton.SetActive(false); OnOffButton.SetActive(false); textScale = (nameInputFieldStyle.fontSize * (Screen.width * 0.001f)); nameInputFieldStyle.fontSize = (int)textScale; serverNameLabel = nameInputFieldStyle; InvokeRepeating("GetHostList", 0.0f, 2.0f); }
void Click(Vector2 position) { Ray ray = Camera.main.ScreenPointToRay(position); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (lobbyActive == false) { if (hit.collider.gameObject.name == "StartButton") { if (!startClicked) { MenuReset(); hostOn.SetActive(true); joinOn.SetActive(true); refreshServerList = true; startClicked = true; } else { MenuReset(); } } else if (hit.collider.gameObject.name == "ExitButton") { Application.Quit(); } else if (hit.collider.gameObject.name == "HostButton") { SavePreferences(); //startserver(); MenuHide(); hostClicked = true; } else if (hit.collider.gameObject.name == "JoinButton") { SavePreferences(); PresentServerList(); } else if (hit.collider.gameObject.name == "OptionButton") { if (!optionsClicked) { TiltButton.SetActive(true); hostOn.SetActive(false); joinOn.SetActive(false); NameButton.SetActive(true); MuteButton.SetActive(true); OnOffButton.SetActive(true); optionsClicked = true; } else { MenuReset(); } } else if (hit.collider.gameObject.name == "TiltButton" && tiltButtonEnabled) { if (tilt) { TiltButton.GetComponent <SpriteRenderer> ().sprite = tiltOff; } else { TiltButton.GetComponent <SpriteRenderer> ().sprite = tiltOn; } tilt = !tilt; SavePreferences(); } else if (hit.collider.gameObject.name == "NameButton") { nameClicked = true; } else if (hit.collider.gameObject.name == "MuteButton") { if (!mute) { OnOffButton.GetComponent <SpriteRenderer> ().sprite = on; AudioListener.pause = true; } else { OnOffButton.GetComponent <SpriteRenderer> ().sprite = off; AudioListener.pause = false; } mute = !mute; SavePreferences(); } else if (hit.collider.gameObject.name == "On/OffButton") { if (!mute) { OnOffButton.GetComponent <SpriteRenderer> ().sprite = on; AudioListener.pause = true; } else { OnOffButton.GetComponent <SpriteRenderer> ().sprite = off; AudioListener.pause = false; } mute = !mute; SavePreferences(); } } } if (backButtonEnabled) { if (BackButtonClicked(position) && !lobbyActive) { MenuReset(); } } }