zoukankan      html  css  js  c++  java
  • 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为预制体内自己所设名字

    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); //释放内存

    Debug.LogWarning("begin");
    yield return new WaitForSeconds(10);
    Instantiate(ab.LoadAsset<GameObject>("Sphere"));
    }

    }

  • 相关阅读:
    CF-807B
    CF-807A
    sort()的升降序函数操作
    CF-805D
    CF-805B
    CF-805A
    CF-796C
    CF-796B
    图论学习四之Disjoint set union并查集
    图论学习三之Shortest Path最短路
  • 原文地址:https://www.cnblogs.com/qipei/p/9885408.html
Copyright © 2011-2022 走看看