Last active
June 16, 2016 16:51
-
-
Save tsubaki/23359b3c9f501baae718e9520b1082aa to your computer and use it in GitHub Desktop.
AssetBundleの読込
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; | |
using AssetBundles; | |
public class CreateInstance : MonoBehaviour { | |
[SerializeField] | |
string variant; | |
IEnumerator Start () { | |
// ロードするアセットの言語を設定 | |
AssetBundleManager.ActiveVariants = new string[] { variant }; | |
#if DEVELOPMENT_BUILD || UNITY_EDITOR | |
AssetBundleManager.SetDevelopmentAssetBundleServer (); | |
#endif | |
// AssetBundle Managerを初期化 | |
if (AssetBundleManager.SimulateAssetBundleInEditor == false) | |
yield return AssetBundleManager.Initialize(); | |
// prefabを取得(ついでに依存関係も解決) | |
var result = AssetBundleManager.LoadAssetAsync("prefab", "Canvas", typeof(GameObject)); | |
yield return result; | |
// prefabをAssetBundleから複製 | |
var obj = result.GetAsset<GameObject>(); | |
GameObject.Instantiate(obj); | |
// AssetBundleを開放 | |
AssetBundleManager.UnloadAssetBundle("prefab"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment