标签:
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);
}
}
标签:
原文地址:http://www.cnblogs.com/ZeroMurder/p/5619325.html