void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit, MenuLayer)) { WorldspaceButton buttonComponent = hit.transform.GetComponent <WorldspaceButton>(); if (buttonComponent != null) { switch (buttonComponent.MenuButton) { case Buttons.Play: Play(); break; case Buttons.Tutorial: Tutorial(); break; case Buttons.Options: Options(); break; case Buttons.Exit: Exit(); break; case Buttons.Sound_Master: SoundMaster(buttonComponent); break; case Buttons.Sound_Music: SoundMusic(buttonComponent); break; case Buttons.Sound_Effects: SoundEffects(buttonComponent); break; case Buttons.Back: Back(); break; case Buttons.Previous: Previous(); break; case Buttons.Next: Next(); break; default: break; } } } } }
public void SoundMaster(WorldspaceButton buttonComponent) { Debug.Log("ToggleSoundMaster"); if (buttonComponent.CheckMark != null) { bool newState = !buttonComponent.CheckMark.activeInHierarchy; buttonComponent.CheckMark.SetActive(newState); if (AudioMixer != null) { AudioMixer.SetFloat("Master", newState? 0f : -80f); } } }
public void SoundEffects(WorldspaceButton buttonComponent) { Debug.Log("ToggleSoundEffects"); if (buttonComponent.CheckMark != null) { bool newState = !buttonComponent.CheckMark.activeInHierarchy; buttonComponent.CheckMark.SetActive(newState); if (AudioMixer != null) { AudioMixer.SetFloat("SFX", newState ? 0f : -80f); AudioMixer.SetFloat("Background", newState ? 0f : -80f); AudioMixer.SetFloat("Objects", newState ? 0f : -80f); } } }
void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { if (MenuObject == null) { Debug.LogError("Menu object not assigned"); return; } if (MenuObject.activeInHierarchy) { // Already open, close. MenuObject.SetActive(false); } else { // Already closed, open. MenuObject.SetActive(true); } } if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit, MenuLayer)) { WorldspaceButton buttonComponent = hit.transform.GetComponent <WorldspaceButton>(); if (buttonComponent != null) { switch (buttonComponent.PauseMenuButton) { case ButtonFunctions.Resume: Resume(); break; case ButtonFunctions.Options: Options(); break; case ButtonFunctions.Exit: Exit(); break; case ButtonFunctions.Controls: Controls(); break; case ButtonFunctions.SoundMaster: ToggleMaster(); break; case ButtonFunctions.SoundEffects: ToggleSounds(); break; case ButtonFunctions.SoundMusic: ToggleMusic(); break; case ButtonFunctions.Back: Back(); break; case ButtonFunctions.MainMenu: MainMenu(); break; } } } } }