I have a NGUI button and it contains UIButton
and UIToggle
script. From another script i want to run its click
event with all relevant button state changes like colour change etc. For this I found this link and here is my code.
public UIButton userManagmentBtn;
public void ClosePanel()
{
Debug.Log("Calling panel Colse");
EventDelegate.Execute(userManagmentBtn.onClick);
}
But the click event is not firing using this: EventDelegate.Execute
No NGUI expert but afaik to invoke all listeners you can simply call
userManagementBtn.OnClick();
Additionally for having the correct coloring etc you could call SetState
userManagementBtn.SetState(UIButtonColor.State.Pressed, true);
Alternatively you could try and send "manually" the according pointer events via ExecuteEvents.Execute
like eg
var pointer = new PointerEventData(EventSystem.current);
ExecuteEvents.Execute(userManagementBtn.gameObject, pointer, ExecuteEvents.pointerEnterHandler);
ExecuteEvents.Execute(userManagementBtn.gameObject, pointer, ExecuteEvents.pointerClickHandler);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.