I started the text with it disabled which works, but its not being enabled after selecting a toggle option. Enabling it on my OnSubmit() function didn’t work either, the text on the next scene is still disabled. Even though all the debug lines do work.
Lines 51 and 57
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System;
//check a box if you want easy, normal, hard, or crazy and have it show the money amount in-game (on the next scene)
public class ChooseDifficulty : MonoBehaviour
{
//Toggle game objects. //use public toggle instead of public GameObject for the toggles
public Toggle isEasy;
public Toggle isNormal;
public Toggle isHard;
public Toggle isCrazy;
public GameObject textObjectEasy;
public GameObject textObjectNormal;
private void Awake()
{
DontDestroyOnLoad(textObjectEasy.gameObject);
}
public void Start()
{
textObjectEasy.gameObject.SetActive(false);
textObjectNormal.gameObject.SetActive(false);
}
//check active toggle
public void ActiveToggle()
{
if (isEasy.isOn)
{
Debug.Log("Player selected easy");
textObjectEasy.gameObject.SetActive(true);
}
else if (isNormal.isOn)
{
Debug.Log("Player selected normal");
textObjectNormal.gameObject.SetActive(true);
}
else if (isHard.isOn)
{
Debug.Log("Player selected hard");
}
else if (isCrazy.isOn)
{
Debug.Log("Player seleced crazy");
}
}
public void OnSubmit() //our button
{
//SUBMITTING DIFFICULTY SELECTION
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
Debug.Log("Difficulty selected");
//textObjectEasy.gameObject.SetActive(true);
//check active toggle through function
ActiveToggle();
}
}