首页 > 其他 > 详细

load Assetbundle

时间:2016-06-27 10:37:40      阅读:193      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!