Hello,
I have a problem with a UIImageButton in a UIDraggablePanel.
When the finger goes out of the draggable panel, I cancel the drag and spawn like a copy of the selected object to be dragged with the finger; it works pretty fine overall, except one thing: the item that was dragged inside the draggable panel (which has a draggablePanelContent component and a UIImageButton one) will not turn back to its "normal" sprite when I think it should.
Here is the code I use to stop the panel from being dragged:
Debug.Log("Stop scroll input!");
//The currentSelectedItem is the object with the finger on, with two UIButtonMessage, one UIImageButton and one UIDragPanelContent
currentSelectedItem.gameObject.SendMessage("OnPress", false);
UICamera.currentTouch.pressed = null;
UICamera.currentTouch.dragged = null;
//Tried to add the refresh to solve my problem, without success
draggablePanel.panel.Refresh();
So here is what happens:
- I press this button => UIImageButton component receives the event and turn the sprite to the pressed state
- I drag it around a bit
- I take it out of the draggable panel (triggering the above code) => UIImageButton component receives the OnPress event with "false" and assigns the normal spriteName to its target (it is correctly assigned); however, in the game view (and on device), the sprite stays "pressed"
- I drag my copy around, the draggable panel does not follow anymore, but the button sprite remains pressed
- In editor, if I release the button anywhere, the sprite finally updates to its normal state, except if I release over the button itself (the hover sprite is the same as normal); in this particular case, the sprite remains "pressed" until I take the mouse out of the collider (wtf??).
- On device, when my finger releases the touch, the sprite simply remains "pressed" until I tap on it again.
Any idea about how to force the update of the button sprite after its value has been changed by UIImageButton component?