Here is the error that I ran into
Assets\Scripts\OptionsScreen.cs(67,15): error CS0128: A local variable or function named ‘vol’ is already defined in this scope
Here is a copy of the code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using UnityEngine.Audio;
public class OptionsScreen : MonoBehaviour
{
public Toggle fullscreenTog, vsyncTog;
public List<ResItem> resolutions = new List<ResItem>();
private int selectedResolution;
public TMP_Text resolutionLabel;
public AudioMixer theMixer;
public TMP_Text mastLabel, musicLabel, sfxLabel;
public Slider mastSlider, musicSlider, sfxSlider;
// Start is called before the first frame update
void Start()
{
fullscreenTog.isOn = Screen.fullScreen;
if (QualitySettings.vSyncCount == 0)
{
vsyncTog.isOn = false;
} else
{
vsyncTog.isOn = true;
}
bool foundRes = false;
for(int i = 0; i < resolutions.Count; i++)
{
if(Screen.width == resolutions_.horizontal && Screen.height == resolutions*.vertical)*_
{
foundRes = true;
selectedResolution = i;
UpdateResLabel();
}
}
if(!foundRes)
{
ResItem newRes = new ResItem();
newRes.horizontal = Screen.width;
newRes.vertical = Screen.height;
resolutions.Add(newRes);
selectedResolution = resolutions.Count - 1;
UpdateResLabel();
}
float vol = 0f;
theMixer.GetFloat(“MasterVol”, out vol);
mastSlider.value = vol;
float vol = 0f;
theMixer.GetFloat(“MusicVol”, out vol);
musicSlider.value = vol;
float vol = 0f;
theMixer.GetFloat(“SFXVol”, out vol);
sfxSlider.value = vol;
mastLabel.text = Mathf.RoundToInt(mastSlider.value + 80).ToString();
musicLabel.text = Mathf.RoundToInt(musicSlider.value + 80).ToString();
sfxLabel.text = Mathf.RoundToInt(sfxSlider.value + 80).ToString();
}
// Update is called once per frame
void Update()
{
}
public void ResLeft()
{
selectedResolution–;
if(selectedResolution < 0)
{
selectedResolution = 0;
}
UpdateResLabel();
}
public void ResRight()
{
selectedResolution++;
if(selectedResolution > resolutions.Count - 1)
{
selectedResolution = resolutions.Count - 1;
}
UpdateResLabel();
}
public void UpdateResLabel()
{
resolutionLabel.text = resolutions[selectedResolution].horizontal.ToString() + “x” + resolutions[selectedResolution].vertical.ToString();
}
public void ApplyGraphics()
{
//Screen.fullScreen = fullscreenTog.isOn;
if(vsyncTog.isOn)
{
QualitySettings.vSyncCount = 1;
}
else
{
QualitySettings.vSyncCount = 0;
}
Screen.SetResolution(resolutions[selectedResolution].horizontal, resolutions[selectedResolution].vertical, fullscreenTog.isOn);
}
public void SetMasterVol()
{
mastLabel.text = Mathf.RoundToInt(mastSlider.value + 80).ToString();
theMixer.SetFloat(“MasterVol”, mastSlider.value);
PlayerPrefs.SetFloat(“MasterVol”, mastSlider.value);
}
public void SetMusicVol()
{
musicLabel.text = Mathf.RoundToInt(musicSlider.value + 80).ToString();
theMixer.SetFloat(“MusicVol”, musicSlider.value);
PlayerPrefs.SetFloat(“MusicVol”, musicSlider.value);
}
public void SetSFXVol()
{
sfxLabel.text = Mathf.RoundToInt(sfxSlider.value + 80).ToString();
theMixer.SetFloat(“SFXVol”, sfxSlider.value);
PlayerPrefs.SetFloat(“SFXVol”, sfxSlider.value);
}
}
[System.Serializable]
public class ResItem
{
public int horizontal, vertical;
}