Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to StartCoroutine using on click listerner

Discussion in 'UGUI & TextMesh Pro' started by RCodelove, Sep 25, 2023.

  1. RCodelove

    RCodelove

    Joined:
    Aug 9, 2023
    Posts:
    22
    Code (CSharp):
    1. public void onPlayClicked()
    2.     {
    3.         frames = new List<string>() {
    4.             "Orient: x= 0.00 |       y= 0.00 |      z= 0",
    5.             "Orient: x= 10.00 |       y= 0.00 |      z= 0",
    6.             "Orient: x= 20.00 |       y= 0.00 |      z= 0",
    7.             "Orient: x= 30.00 |       y= 0.00 |      z= 0",
    8.             "Orient: x= 40.00 |       y= 0.00 |      z= 0",
    9.         };
    10.  
    11.         // play = true;
    12.         StartCoroutine(PlayerCoroutine());
    13.     }

    I want to start coroutine and rotate gameobject using frame data, when I invocked onPlayClicked StartCoroutine(PlayerCoroutine()) doesn't work but when I put StartCoroutine(PlayerCoroutine()) in the Start() method gameObject rotate fine