Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active December 16, 2015 02: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 tsubaki/6fae8c1fca9bdb85134b to your computer and use it in GitHub Desktop.
Save tsubaki/6fae8c1fca9bdb85134b to your computer and use it in GitHub Desktop.
シーン読んだ後にリソースを読む
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