2014-10-30 7 views
1

문제가 있습니다. 이제 조건이 점수 2 일 때 Unity에서 게임을 개발 중입니다. 코드 변경 장면 (Application.LoadLevel)을 수행하기 전에 10 초 동안 기다리고 싶습니다. (개발을 위해 C#을 사용 중입니다)Unity3d에서 Application.LoadLevel이 작동하지 않습니다.

이 코드는 그것은 "scenea_5" 로 변경됩니다 점수 = 2 그것은 십초

void OnTriggerEnter(Collider collider){ 

    if (collider.name == front_hztleft) { 
     audio.Play(); 
    } 

    if (collider.name == left_hztleft) { 
     audio.Play(); 
     score ++; 
     Debug.Log (string.Format (scoreSyntax, score)); 
     endtime = DateTime.Now.ToString("HH:mm:ss"); 
     InsertResult(); 
    } 


    if (score == 2) { 
     StartCoroutine(Waiting()); 
     Application.LoadLevel("scene_a5"); 

    } 
} 
IEnumerator Waiting() 
{ 
    yield return new WaitForSeconds (10); 
} 

것은 실행 오류가없는 것은 아니다 컴파일 기다릴 수 없습니다.

답변

1

Coroutine 안에 장면로드를 넣습니다.

yield return new WaitForSeconds(10); 
Application.LoadLevel("scene_a5"); 
관련 문제