けいごのなんとか

Unityユーザーとしてのブログ。ギリギリ路線走ってます。

あれ?Application.LoadLevelAdditiveAsyncで複数シーンの非同時ロードが可能になってる?

検証で試したコード

Unity4.5ではasyncOperation2.progressは0を返し続けるけど、Unity5だと0.9を返す。

using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour
{
    AsyncOperation asyncOperation1;
    AsyncOperation asyncOperation2;

    IEnumerator Start ()
    {
        asyncOperation1 = Application.LoadLevelAdditiveAsync (1);
        asyncOperation1.allowSceneActivation = false;
                
        while (asyncOperation1.progress < 0.9f) {
            yield return new WaitForEndOfFrame ();
        }

        Debug.Log ("done: asyncOperation1");
        asyncOperation2 = Application.LoadLevelAdditiveAsync (2);
        asyncOperation2.allowSceneActivation = false;

        while (asyncOperation2.progress < 0.9f) {
            Debug.Log (asyncOperation2.progress);
            yield return new WaitForEndOfFrame ();
        }

        Debug.Log ("done: asyncOperation2");
    }

    void OnGUI ()
    {
        if (GUILayout.Button ("Additive")) {
            asyncOperation1.allowSceneActivation = true;
            asyncOperation2.allowSceneActivation = true;
        }
    }
    
}