This repository has been archived on 2026-04-30. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Last-Ember/Scripts/User Interface/Menus/OptionsOptions/Volume.cs
T
2019-03-08 09:54:14 +11:00

40 lines
937 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
namespace MenuSystem {
public class Volume : MenuOption {
//component references
ConfigurationManager configManager;
TextMeshProUGUI text;
void Start() {
configManager = ConfigurationManager.Instance;
text = GetComponent<TextMeshProUGUI>();
configManager.volume = (configManager.volume != null && configManager.volume != 0 ? configManager.volume : 100f);
text.text = configManager.volume.ToString();
UpdateMasterVolume();
}
public override void Execute() {
//DO NOTHING
}
public override void Scroll(float x) {
//DO NOTHING
configManager.volume += x;
configManager.volume = Mathf.Clamp(configManager.volume, 0f, 100f);
text.text = configManager.volume.ToString();
UpdateMasterVolume();
}
void UpdateMasterVolume() {
AudioListener.volume = configManager.volume / 100f;
}
}
}