I have a button with a click handler assigned to it. In my script I want to trigger that click function without the user clicking the button. How can I do this?
I figured with gameObject.GetComponent<Button>().onClick;
it would work, but it doesn't.
This should work:
gameObject.GetComponent<Button>().onClick.Invoke();
I dont even know what
onClick
does
Go to the documentation: