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"));
    }

    }

  • 相关阅读:
    SpringMVC听课笔记(一:SpringMVC概述)
    IDEA快捷键
    Java学习方法以及eclipse看jdk源码
    SpringMVC参数绑定
    正向代理、反向代理
    代理模式
    面试准备
    一致性哈希
    synchronized的底层探索
    哈夫曼编码
  • 原文地址:https://www.cnblogs.com/qipei/p/9885408.html
Copyright © 2011-2022 走看看