I need to simulate a click on a button in a Unity unit test so that the button event handler is triggered and I compare the results. I tried:
GameObject facebookBtn = GameObject.FindGameObjectWithTag("Player"); // Кнопка bool res = ExecuteEvents.Execute<IPointerClickHandler>( facebookBtn, new PointerEventData(EventSystem.current), ExecuteEvents.pointerClickHandler);
As far as I understood, the click works because
res = true , and the button handler does not fire. It seems to me that this is due to the fact that this is performed in editor mode, although Unit tests are not performed differently in the unit. Also getting the error:
Ignoring menu item NGUI because it is in no submenu.
Has anyone encountered something similar?
If the click itself is not important to you, but the method, you can call the method itself.
If you need an imitation of user actions, then it is better to imitate it.
If the button is on the keyboard:
If you need a simulation of a little mouse on the NGUI button in unit3d: