I have a Toggle that is (and must be) unchecked by default.
The nearby TextField visility/active-state must be tied to the Toggle state.
Problem: the TextField stays visible.
By adding this to Update() it does work:
But I don't like that it's being checked every frame.
Any Ideas how to hide the TextField properly from Init() or based on a event?
The nearby TextField visility/active-state must be tied to the Toggle state.
Problem: the TextField stays visible.
C#:
JSONStorableBool jbShowBands;
UIDynamicTextField bandInfoText;
// inside Init() ...
jbShowBands = Utils.SetupToggle(this, "Show Bands", false); // Toggle checkbox off by default (MacGruber Utils)
jbShowBands.setCallbackFunction += ToggleShowBands;
jsBandInfoText = new JSONStorableString("BandInfoText", "myText");
bandInfoText = CreateTextField(jsBandInfoText);
bandInfoText.height = 300f;
// does not hide TextField if called in Init(), does hide TextField if called in Update()
bandInfoText.gameObject.SetActive(false);
// Toggle Callback
private static void ToggleShowBands(bool b)
{
spectrum.showBands = b;
bandInfoText.gameObject.SetActive(b);
}
By adding this to Update() it does work:
C#:
if (!spectrum.showBands)
bandInfoText.gameObject.SetActive(false);
Any Ideas how to hide the TextField properly from Init() or based on a event?
Last edited: