Here is a strange behaviour that I found:
Neither "test 1" nor "test 2" will appear on the console, the code seems not to be executed. But, as a workaround, this would work:
Yield not working with onClick.AddListener.
Code (JavaScript):
- function Start()
- {
- button.GetComponent(UI.Button).onClick.AddListener( BtnFunction );
- }
- function BtnFunction()
- {
- print("test 1");
- yield WaitForSeconds(1);
- print("test 2");
- }
Neither "test 1" nor "test 2" will appear on the console, the code seems not to be executed. But, as a workaround, this would work:
Code (JavaScript):
- function Start()
- {
- button.GetComponent(UI.Button).onClick.AddListener( Temp );
- }...