Last active
January 3, 2016 23:08
LoadLevelAsyncを使ったシーンの非同期読み込みテスト。LoadLevelAsyncはPro用の機能。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class testLoadAsync : MonoBehaviour { | |
private AsyncOperation async; | |
IEnumerator Start(){ | |
// 非同期でロード開始 | |
async = Application.LoadLevelAsync("NextScene"); | |
// デフォルトはtrue。ロード完了したら勝手にシーンきりかえ発生しないよう設定。 | |
async.allowSceneActivation= false; | |
// 非同期読み込み中の処理 | |
while(!async.isDone){ | |
Debug.Log(async.progress * 100 + "%"); | |
yield return new WaitForSeconds(0); | |
} | |
yield return async; | |
} | |
/* | |
// Use this for initialization | |
void Start () { | |
} | |
*/ | |
// Update is called once per frame | |
void Update () { | |
if(Input.GetMouseButtonDown(0)){ | |
// タッチしたら遷移する(検証用) | |
async.allowSceneActivation= true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NextSceneというダミーのシーンをつくっといてビルド&セッティングで設定しておくこと。