码迷,mamicode.com
首页 > 其他好文 > 详细

load Assetbundle

时间:2016-06-27 10:40:07      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

using UnityEngine;
using System.Collections;

public class ZYLOAdAssetBundle : MonoBehaviour {

 

//不同平台下StreamingAssets的路径是不同的,这里需要注意一下。
public static readonly string PathURL =
#if UNITY_ANDROID
"jar:file://" + Application.dataPath + "!/assets/";
#elif UNITY_IPHONE
Application.dataPath + "/Raw/";
#elif UNITY_STANDALONE_WIN || UNITY_EDITOR
"file://" + Application.dataPath + "/StreamingAssets/";
#else
string.Empty;
#endif

 

void OnGUI()
{
if (GUILayout.Button("ThisAssetbundle"))
{
//StartCoroutine(LoadMainGameObject(Application.dataPath + "/StreamingAssets/" + "Capsule.assetbundle"));
StartCoroutine(LoadMainGameObject("http://192.168.0.98/MyItems/MyCard/Capsule.assetbundle"));
}
}

//读取一个资源

private IEnumerator LoadMainGameObject(string path)
{
WWW bundle = new WWW(path);

yield return bundle;

//加载到游戏中
yield return Instantiate(bundle.assetBundle.mainAsset);

bundle.assetBundle.Unload(false);
}

}

load Assetbundle

标签:

原文地址:http://www.cnblogs.com/ZeroMurder/p/5619325.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!