merge with riz worked!

This commit is contained in:
Zoe J committed 2022-02-21 19:40:12 -06:00
1 parent 44e4c7368f
commit 1bd8897d05
8 files changed
+19 -15

No files matched your search

@@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
public class AudioManager : MonoBehaviour
{
public AudioMixer theMixer;
void Start()
{
if (PlayerPrefs.HasKey("MasterVol"))
{
theMixer.SetFloat("MasterVol", PlayerPrefs.GetFloat("MasterVol"));
}
if (PlayerPrefs.HasKey("MusicVol"))
{
theMixer.SetFloat("MusicVol", PlayerPrefs.GetFloat("MusicVol"));
}
if (PlayerPrefs.HasKey("SFXVol"))
{
theMixer.SetFloat("SFXVol", PlayerPrefs.GetFloat("SFXVol"));
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ff8c6d62e5fc0f6478840a18add47f3a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,135 @@
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 masterLabel, musicLabel, SFXLabel;
public Slider masterSlider, 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[i].horizontal && Screen.height == resolutions[i].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);
masterSlider.value = vol;
theMixer.GetFloat("MusicVol", out vol);
musicSlider.value = vol;
theMixer.GetFloat("SFXVol", out vol);
SFXSlider.value = vol;
masterLabel.text = Mathf.RoundToInt(masterSlider.value *5/3+100).ToString();
musicLabel.text = Mathf.RoundToInt(musicSlider.value *5/3+100).ToString();
SFXLabel.text = Mathf.RoundToInt(SFXSlider.value *5/3+100).ToString();
}
// Update is called once per frame
void Update()
{
}
public void ResLeft()
{
selectedResolution--;
if (selectedResolution < 0)
{
selectedResolution = resolutions.Count - 1;
}
UpdateResLabel();
}
public void ResRight()
{
selectedResolution++;
if (selectedResolution > resolutions.Count - 1)
{
selectedResolution = 0;
}
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()
{
masterLabel.text = Mathf.RoundToInt(masterSlider.value *5/3+100).ToString();
theMixer.SetFloat("MasterVol", masterSlider.value);
PlayerPrefs.SetFloat("MasterVol", masterSlider.value);
}
public void SetMusicVol()
{
musicLabel.text = Mathf.RoundToInt(musicSlider.value *5/3+100).ToString();
theMixer.SetFloat("MusicVol", musicSlider.value);
PlayerPrefs.SetFloat("MusicVol", musicSlider.value);
}
public void SetSFXVol()
{
SFXLabel.text = Mathf.RoundToInt((SFXSlider.value *5/3+100)).ToString();
theMixer.SetFloat("SFXVol", SFXSlider.value);
PlayerPrefs.SetFloat("SFXVol", SFXSlider.value);
}
}
[System.Serializable]
public class ResItem
{
public int horizontal, vertical;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 447f7ce6530519346b944ce158890ad6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: