public void restartOnClick(){ Debug.Log (“Restart”); }
The problem is that after clicking this button the whole game stops working for few seconds (10 or 15 seconds) and than on the console I can see around 90 messages saying “Restart”. (I’ve expected one message immediately after clicking the button). How can I fix it?
I dunno — perhaps you’re doing something silly like calling AddListener in your Update event (so it’s getting added a gazillion times).
Why are you adding the listener from code at all? Your restartOnClick method is public; you should probably just hook this event up in the inspector.
There are important differences between events hooked up in code and events hooked up in the inspector… perhaps my video about UnityEvents will have some insights for you?