Hello. How would I create (using the new 4.6 UI beta tools), a button that had an inactive/active state? For example, I have a sub-menu that I want to open when I click on this button, but when I click on the button again, it closes it, such as a toggle.
What would be the best way to approach this? In the on click events for the button, I haven’t found a way to switch events around…
using UnityEngine;
using UnityEngine.UI;
public class ToggleExtension : MonoBehaviour {
public Image bkg;
public void toggleChangedHandler()
{
if (GetComponent<Toggle>().isOn)
{
bkg.color = new Color(bkg.color.r, bkg.color.g, bkg.color.b, 0);
}
else
{
bkg.color = new Color(bkg.color.r, bkg.color.g, bkg.color.b, 255);
}
}
}