Quantcast
Channel: UGUI & TextMesh Pro
Viewing all articles
Browse latest Browse all 23263

Yield not working with onClick.AddListener.

$
0
0
Here is a strange behaviour that I found:

Code (JavaScript):
  1. function Start()
  2. {
  3.     button.GetComponent(UI.Button).onClick.AddListener( BtnFunction );
  4. }
  5.  
  6. function BtnFunction()
  7. {
  8.     print("test 1");
  9.     yield WaitForSeconds(1);
  10.     print("test 2");
  11. }

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):
  1. function Start()
  2. {
  3.     button.GetComponent(UI.Button).onClick.AddListener( Temp );
  4. }...
Yield not working with onClick.AddListener.

Viewing all articles
Browse latest Browse all 23263

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>