unity 协同

    void Update () {
      if(Input .GetKeyDown (KeyCode .W ))
        {
            StartCoroutine ("Test");
        }
    }
    IEnumerator Test()
    {
        while (Cube1 .position .x<6)
        {
            Cube1 .Translate (transform .right *3*Time .deltaTime );
            yield return null;
        }
        yield return new  WaitForSeconds(2);
        while (Cube2 .position .x<6)
        {
            Cube2 .Translate (transform .right *3*Time .deltaTime );
            yield return null;
        }
    }
原文地址:https://www.cnblogs.com/xiaolongchase/p/3291745.html