Skip to content

Instantly share code, notes, and snippets.

@tsubaki tsubaki/Load.cs
Last active Dec 16, 2015

Embed
What would you like to do?
シーン読んだ後にリソースを読む
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class Load : MonoBehaviour {
IEnumerator Start ()
{
// ステージを読む
var stageAB = AssetBundle.LoadFromFile (Application.streamingAssetsPath + "/stage");
SceneManager.LoadScene ("stage", LoadSceneMode.Additive);
// モデルデータやテクスチャを非同期でロード
var modelABResult = AssetBundle.LoadFromFileAsync (Application.streamingAssetsPath + "/ball");
yield return new WaitWhile (() => modelABResult.isDone == false);
// missingな設定を再設定
var gimic = GameObject.Find ("Gimic");
gimic.SetActive (false);
gimic.SetActive (true);
// 依存の解決に1F何故か必要
yield return null;
// AssetBundleを解放
modelABResult.assetBundle.Unload (false);
stageAB.Unload (false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.