Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Audio;
- using UnityEngine.UI;
- public class UISettings : MonoBehaviour {
- public AudioMixer audioMixer;
- public Dropdown resolutionsDropdown;
- public Toggle fullScreenToggle;
- Vector2Int[] resolutions;
- void Start() {
- resolutions = new Vector2Int[3];
- resolutions[0] = new Vector2Int(800, 600);
- resolutions[1] = new Vector2Int(1024, 768);
- resolutions[2] = new Vector2Int(1366, 768);
- }
- public void SetResolution(int resolutionIndex) {
- Vector2Int resolution = resolutions[resolutionIndex];
- Screen.SetResolution(resolution.x, resolution.y, Screen.fullScreen);
- }
- public void SetVolume(float volume) {
- audioMixer.SetFloat("volume", volume);
- }
- public void SetQuality(int qualityIndex) {
- QualitySettings.SetQualityLevel(qualityIndex);
- }
- public void SetFullscreen(bool isFullscreen) {
- Screen.fullScreen = isFullscreen;
- }
- public void OnExit() {
- #if UNITY_EDITOR
- UnityEditor.EditorApplication.isPlaying = false;
- #else
- Application.Quit();
- #endif
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement