I needed to distinguish between the button unselecting due to clicking another button, vs due to clicking the background. My 3D world input is handled as NGUI fallthrough input.
Clicking the background de-selects the button but should not disable that buttons's targeting mode.
I have implemented this on my button script:
void OnSelect(bool sel)
{
if (sel == false)
{
if(UICamera.hoveredObject.tag == "Untagged")
return;
targetingMode = false;
}
}
The hoveredObject.tag is always "Untagged" if you're not clicking on an NGUI button that has been assigned a tag. Basically means I need to tag all my buttons now, which is not a big deal.