下面的代码是非Include in Build模式
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.U2D;
public class loadpre : MonoBehaviour {
public string prefabBundle = "preab_late";
public string saBundle = "atlasab_late";
IEnumerator Start ()
{
var loadOp = new WWW("file://" + Application.streamingAssetsPath + "/" + prefabBundle);
yield return loadOp;
var prepre = loadOp.assetBundle.LoadAsset<GameObject>("prop_parachute");
GameObject.Instantiate(prepre);
}
void OnEnable()
{
SpriteAtlasManager.atlasRequested += RequestLateBindingAtlas;
}
void OnDisable()
{
SpriteAtlasManager.atlasRequested -= RequestLateBindingAtlas;
}
void RequestLateBindingAtlas(string tag, System.Action<SpriteAtlas> action)
{
StartCoroutine(LoadFromAssetBundle(tag, action));
}
IEnumerator LoadFromAssetBundle(string tag, System.Action<SpriteAtlas> action)
{
var loadOp = new WWW("file://" + Application.streamingAssetsPath + "/" + saBundle);
yield return loadOp;
var sa = loadOp.assetBundle.LoadAsset<SpriteAtlas>(tag);
action(sa);
}
}