Open-sourced some code
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
namespace MenuSystem {
|
||||
public class TextSpeed : MenuOption {
|
||||
//component references
|
||||
ConfigurationManager configManager;
|
||||
TextMeshProUGUI text;
|
||||
|
||||
void Start() {
|
||||
configManager = ConfigurationManager.Instance;
|
||||
text = GetComponent<TextMeshProUGUI>();
|
||||
configManager.textSpeed = (configManager.textSpeed != null && configManager.textSpeed != "" ? configManager.textSpeed : "Normal");
|
||||
text.text = configManager.textSpeed;
|
||||
}
|
||||
|
||||
override public void Execute() {
|
||||
switch(configManager.textSpeed) {
|
||||
case "Normal":
|
||||
configManager.textSpeed = "Slow";
|
||||
break;
|
||||
|
||||
case "Slow":
|
||||
configManager.textSpeed = "Fast";
|
||||
break;
|
||||
|
||||
case "Fast":
|
||||
configManager.textSpeed = "Normal";
|
||||
break;
|
||||
}
|
||||
|
||||
text.text = configManager.textSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user