- Home /
Question by
MARTYELECBREN · Apr 12 at 01:17 PM ·
buttontogglelistener
How to get button to be one click to activate like a button rather than one click to turn on and one click to turn off like a "Lever"
I'm trying to make it so that an information tab appears when a button is pressed, as it stands I have it working however you need to click the information button twice, Once to activate and once to deactivate which is fine, until you either select another information button or close the initial information bar using other means rather than clicking the button for a second time
The problem this causes is that the programme is still reading the first info tab as being open and you still need to click it twice even if it is not visible in order to make it reappear.
I know that the issue is coming from this piece of code but I can't quite see where.
public void activateIcon()
{
iconSelected = !iconSelected;
iconTool.DeselectAll();
if (iconSelected) { EventSystem.current.currentSelectedGameObject.GetComponent<Image>().color = iconTool.selectedColor; displayInfo(); }
else { EventSystem.current.currentSelectedGameObject.GetComponent<Image>().color = iconTool.UnselectedColor; }
}
Comment