AB打包Day01
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Load : MonoBehaviour {
// Use this for initialization
void Start () {
string _abpath = Application.streamingAssetsPath + "\\Windows\\sp";///此處sp為預(yù)制體內(nèi)自己所設(shè)名字
AssetBundle ab = AssetBundle.LoadFromFile(_abpath);
if (ab == null)
{
Debug.LogError("加載AB失敗");
return;
}
//GameObject CubeObj = ab.LoadAsset<GameObject>("Cube");
GameObject CubeObj = ab.LoadAsset<GameObject>("Sphere,);
if (CubeObj != null)
{
//加載成功
Instantiate(CubeObj );
}
else
{
Debug.LogError("該資源不存在");
}
StartCoroutine("Creat", ab);
}
// Update is called once per frame
void Update () {
}
IEnumerator Creat(AssetBundle ab)
{
yield return new WaitForSeconds(3);
ab.Unload(false); //釋放內(nèi)存
Debug.LogWarning("begin");
yield return new WaitForSeconds(10);
Instantiate(ab.LoadAsset<GameObject>("Sphere"));
}
}
?
轉(zhuǎn)載于:https://www.cnblogs.com/qipei/p/9885408.html
總結(jié)
- 上一篇: [JZOJ5281]钦点题解--瞎搞+链
- 下一篇: SQL------Hint