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;
        }
    }
相關文章
相關標籤/搜索