Download presentation
Presentation is loading. Please wait.
1
Game Settings Richard Gesick
2
Objectives Creating video configurations Creating audio configurations
Saving and loading custom settings Modifying Unity's native settings Creating an Options GUI Using PlayerPrefs to save settings
3
Options menu aspects of the game that you can modify
most common practice is to make a few preset options available to the player to choose from with varying quality of output. If a player doesn't have a high performance computer, they may need to play the game on low settings, while a player with a great computer can play on the highest settings Another option is to allow the player to modify different parts of the game output such as shadows or anti-aliasing.
4
video configurations When it comes to performance, the video settings are perhaps the most important. Changing something as simple as the shadows can greatly change how a player can smoothly play the game
5
shadows public void ToggleShadows(int newToggle) { Light[] lights = GameObject.FindObjectsOfType<Light>(); foreach (Light light in lights) if (newToggle == 0) light.shadows = LightShadows.None; else if (newToggle == 1) light.shadows = LightShadows.Hard; else light.shadows = LightShadows.Soft; }
6
FOV field of view is a video setting that doesn't really affect performance that much, but it is an option that many PC gamers like to modify. The field of view literally means what it's called; it determines how big the view port is for the player to see the game. It's measured by angle degrees and can also be measured vertically, horizontally, or diagonally. Typically, the field of view is measured diagonally for video games.
7
FOV public void SetFOV(float newFOV) { Camera.main.fieldOfView = newFOV; }
8
Resolution public void SetResolution(int Res, int Full) { bool fs = Convert.ToBoolean(Full); switch(Res) case 0: Screen.SetResolution(1920, 1080, fs); break; case 1: Screen.SetResolution(1600, 900, fs); case 4: Screen.SetResolution(640, 400, fs); }
9
Anti-aliasing Aliasing in a game is where the models being rendered have jagged edges. Anti-aliasing is what the game renderer does to smooth out those jagged edges.The renderer will blur the edges slightly to make them smooth. This is one of the options that will make your game look great, but will also slow down the performance.
10
Anti-aliasing public void SetAA(int Samples) {
if(Samples == 0 || Samples == 2 || Samples == 4 || Samples == 8) QualitySettings.antiAliasing = Samples; } The way anti-aliasing works is that it will blur the edges by a number of samples. If the number of samples is zero, no anti-aliasing will happen
11
vsync Vsync affects how the frames are rendered. With vsync on, the game will wait until the frame has finished rendering before starting the next frame. With vsync off, the game will start to render the next frame while the current frame is still being rendered. The bonus of vsync being off is that the game will render faster but could cause an effect called screen tear, which shows an obvious line on the screen caused by the frames overlapping each other
12
vsync public void SetVsync(int Sync) { QualitySettings.vSyncCount = Sync; }
13
audio configurations volumes for background music, sound effects, and the atmospheric sounds public void SetBG(float bgVolume) { AudioSource[] audios = GameObject.FindObjectsOfType<AudioSource>(); foreach(AudioSource source in audios) if(source.name.Contains("BG")) { source.GetComponent<BG_Music_Manager>().bgVolume = PlayerPrefs.GetFloat("bgVolume"); } else if(source.name.Contains("SFX")) { source.GetComponent<SFX_Manager>().sfxVolume = PlayerPrefs.GetFloat("sfxVolume");
14
speaker mode public void SetAudioType(string SpeakerMode) { switch(SpeakerMode) case "Mono": AudioSettings.speakerMode = AudioSpeakerMode.Mono; break; case "Stereo": AudioSettings.speakerMode = AudioSpeakerMode.Stereo; case "Surround 7.1": AudioSettings.speakerMode = AudioSpeakerMode.Mode7point1; }
15
The GUI The normal buttons for resolution, but consider sliders for FOV and volumes and toggles for AA and full screen if(GUI.Button(new Rect(25, 20, 75, 20), "High")) GetComponent<Video_Config>().SetResolution(0, 3); GUI.Label(new Rect(25, 40, 100, 30), "Field of View"); fov = GUI.HorizontalSlider(new Rect(115, 45, 100, 30), fov, 60.0f, f); GUI.Label(new Rect(25, 60, 100, 30), "Antialiasing"); aa = GUI.Toggle(new Rect(115, 60, 100, 30), aa, " On/Off"); GUI.Label(new Rect(25, 125, 100, 30), "FullScreen"); full = GUI.Toggle(new Rect(95, 125, 100, 30), fullscreen, " On/ Off");
16
The GUI GUI.Label(new Rect(25, 160, 150, 30), "Music Volume"); volBG = GUI.HorizontalSlider(new Rect(25, 180, 100, 30), volBG, 0.00f, 1.00f); GUI.Label(new Rect(25, 200, 150, 30), "SFX Volume"); volSFX = GUI.HorizontalSlider(new Rect(25, 220, 100, 30), volSFX, 0.00f, 1.00f);
17
Saving the values Standard saving with player prefs but note the boolean tests. PlayerPrefs.SetInt("Custom_Resolution", res); PlayerPrefs.SetInt("Custom_Full",Convert.ToInt32(fullscreen)); if(aa) PlayerPrefs.SetInt("Custom_AA", 1); else PlayerPrefs.SetInt("Custom_AA", 0);
18
Loading the values . . . volATM = PlayerPrefs.GetFloat("atmVolume");
fov = PlayerPrefs.GetFloat("Custom_FOV"); aa = Convert.ToBoolean(PlayerPrefs.GetInt("Custom_AA")); shadows = Convert.ToBoolean(PlayerPrefs.GetInt("Custom_Shadows"));
19
Project 3 notes You will need to be able to save and load the configuration settings to/from a file. It can be flat or xml.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.