Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@masayuki5160
Last active January 3, 2016 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masayuki5160/8532611 to your computer and use it in GitHub Desktop.
Save masayuki5160/8532611 to your computer and use it in GitHub Desktop.
LoadLevelAsyncを使ったシーンの非同期読み込みテスト。LoadLevelAsyncはPro用の機能。
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;
}
}
}
@masayuki5160
Copy link
Author

NextSceneというダミーのシーンをつくっといてビルド&セッティングで設定しておくこと。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment