public void Load() { //New SettingsData for the data loaded from settings file SettingsData data = SettingsBinary.LoadSettingsData(); //Set the audioMixer volume to the data soundLevel audioMixer.SetFloat("Volume", data.soundLevel); //Change the volume text to show the volume percentage volumeText.text = "Master Volume: " + Mathf.Round((((80f + data.soundLevel) / 80) * 100)).ToString() + "%"; //Set the resolution dropdown value to the Data resolutionIndex resolutionDropdown.value = data.resolutionIndex; //Set the quailty dropdown value to the data quailtyIndex quailtyDropdown.value = data.quailtyIndex; //Set the quality level using the quailtyIndex QualitySettings.SetQualityLevel(data.quailtyIndex); //Set the volumeSlider value using the data sound level volumeSlider.value = data.soundLevel; //Set forward basied on data forward forward = (KeyCode)System.Enum.Parse(typeof(KeyCode), data.forward); //Set the forward text to forward forwardButton.text = forward.ToString(); //Set backward basied on data backward backward = (KeyCode)System.Enum.Parse(typeof(KeyCode), data.backward); //Set the backward text to backward backwardButton.text = backward.ToString(); //Set left basied on data left left = (KeyCode)System.Enum.Parse(typeof(KeyCode), data.left); //Set the left text to left leftButton.text = left.ToString(); //Set right basied on data right right = (KeyCode)System.Enum.Parse(typeof(KeyCode), data.right); //Set the right text to right rightButton.text = right.ToString(); //Set jump basied on data jump jump = (KeyCode)System.Enum.Parse(typeof(KeyCode), data.jump); //Set the jump text to jump jumpButton.text = jump.ToString(); //Set interact basied on data interact interact = (KeyCode)System.Enum.Parse(typeof(KeyCode), data.interact); //Set the interact text to interact interactButton.text = interact.ToString(); //Set inventory basied on data inventory inventory = (KeyCode)System.Enum.Parse(typeof(KeyCode), data.inventory); //Set the inventory text to inventory inventoryButton.text = inventory.ToString(); }
public Text forwardButton, backwardButton, leftButton, rightButton, inventoryButton, interactButton, jumpButton; //Buttons for all the keycodes void Start() { //Get the resolutions the screen can be and set it into the array resolutions = Screen.resolutions; //Clear all options on the dropdown resolutionDropdown.ClearOptions(); //New list for all the resolution options List <string> options = new List <string>(); //Set the currentResolutionIndex to zero int currentResolutionIndex = 0; //For all resolutions for (int i = 0; i < resolutions.Length; i++) { //Set the new string option to contain the resoulution width and heigh string option = resolutions[i].width + " x " + resolutions[i].height; //Add the option to the list options.Add(option); //if the resolution matches the current resoultion if (resolutions[i].width == Screen.currentResolution.width && resolutions[i].height == Screen.currentResolution.height) { //Set the currentResolutionIndex to i currentResolutionIndex = i; } } //Set the quailty dropdown value to be the quality level quailtyDropdown.value = QualitySettings.GetQualityLevel(); //Add the options to resolution resolutionDropdown.AddOptions(options); //Set the dropdown value to the current resolutionIndex resolutionDropdown.value = currentResolutionIndex; //Refresh the shown value resolutionDropdown.RefreshShownValue(); //If the save file for settings isnt null if (SettingsBinary.LoadSettingsData() != null) { //Load settings Load(); } else { //Save settings Save(); } }
public void Save() { //Save settings data SettingsBinary.SaveSettingData(this); }