So I have a basic script with hard coded subtitles and a settings menu. My goal is that when the player say, choses to turn the subtitles on/off in the menu, those settings are applied to the entire game.
Here is my subtitle code:
public GameObject textBox;
void Start()
{
StartCoroutine(TheSequence());
}
IEnumerator TheSequence()
{
Debug.Log("Subtitles script reached");
//wait for 1 seconds before showing text
yield return new WaitForSeconds(1);
textBox.GetComponent<Text>().text = "Test Subtitle";
//wait for three seconds before changing text
yield return new WaitForSeconds(3);
textBox.GetComponent<Text>().text = "";
yield return new WaitForSeconds(1);
textBox.GetComponent<Text>().text = "Test Subtitle";
}
I used to have a button in scene that toggled the subtitles on/off that looked like:
public bool isSubtitle = true;
public void ToggleSubs()
{
if (isSubtitle == false)
{
textBox.SetActive(true);
isSubtitle = true;
return;
}
if (isSubtitle == true)
{
textBox.SetActive(false);
isSubtitle = false;
return;
}
},So I have a very basic subtitle script and a menu. My goal is to make it so that when a user changes the settings in the menu, that they change to reflect that in the entire game.
I.e. turn subtitles on/off for the whole game
This is my script for the subtitles.
public GameObject textBox;
public bool isSubtitle = true;
void Start()
{
StartCoroutine(TheSequence());
}
IEnumerator TheSequence()
{
Debug.Log("Subtitles script reached");
//wait for 1 seconds before showing text
yield return new WaitForSeconds(1);
textBox.GetComponent<Text>().text = "Test subtitle";
//wait for three seconds before changing text
yield return new WaitForSeconds(3);
textBox.GetComponent<Text>().text = "";
yield return new WaitForSeconds(1);
textBox.GetComponent<Text>().text = "Test subtitle 2";
}
I used to have a button in the scene itself to toggle whether they were on or off that looked like this.
public void ToggleSubs()
{
if (isSubtitle == false)
{
textBox.SetActive(true);
isSubtitle = true;
return;
}
if (isSubtitle == true)
{
textBox.SetActive(false);
isSubtitle = false;
return;
}
}
However as stated before, this has to be in the scene, and I want a settings menu that applies this setting to the whole game