Answer the question
In order to leave comments, you need to log in
How to programmatically click on a UI Button in Unity?
Hello. I ask for help from people who know Unity.
There is a UnityEngine.UIElements.Button button, to which I assigned several functions to the onClick event in the interface of the Button component.
When you click on the button, everything works fine, there are no problems. But I need to simulate pressing this button programmatically, from code.
Found a solution like myButton.gameObgect.GetComponent().onClick.Invoke() but it doesn't work. Compilation error (onClick has no such method). In the documentation, such a construction is described only for the old unit, but not for the version 2019.3 used.
How to programmatically click on a button?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question