0
public void load(string name) {
    StartCoroutine(LoadNextLevel(name));
}

IEnumerator LoadNextLevel(string name) {
    AsyncOperation ao = Application.LoadLevelAsync(name);
    ao.allowSceneActivation = false;

    while( ao.progress < 0.9f ) {
        yield return new WaitForEndOfFrame();
    }
    //次のレベルに遷移
    ao.allowSceneActivation = true;

    yield return null;
}

上記のスクリプトをシーン遷移時に起動しています。
A⇒B⇒A⇒Bといったシーン遷移を繰り返した場合、2回目以降のシーン遷移が行われない場合があります。具体的にはao.progressの値が常に0のままになります。
原因や解決策などご存知でしょうか。

unity 5.2.2

1 件の回答 1

1

シーン遷移が重なると確かに同じ現象になりました。
おそらく排他的にシーン遷移を行えば問題なくなるかと思います。

簡単に最低限の改造をしてみました。

AsyncOperation ao;

public void load(string name) {
    if (ao != null) return;
    StartCoroutine(LoadNextLevel(name));
}

IEnumerator LoadNextLevel(string name) {
    ao = Application.LoadLevelAsync(name);
    ao.allowSceneActivation = false;

    while( ao.progress < 0.9f ) {
        yield return new WaitForEndOfFrame();
    }
    //次のレベルに遷移
    ao.allowSceneActivation = true;
    ao = null;

    yield return null;
}

この質問に回答するには、ログインする必要があります。

求めていた回答ではありませんか? のタグが付いた他の質問を参照する。