zoukankan      html  css  js  c++  java
  • AB打包Day02

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class LoadMan : MonoBehaviour {

    // Use this for initialization
    public string ABName;
    string _abPath ;

    string _manPath;
    private List<AssetBundle> ManListAB;

    void Start ()
    {
    ManListAB = new List<AssetBundle>();
    //capsulepre
    //www
    _abPath = Application.streamingAssetsPath + "/Windows/";
    _manPath = Application.streamingAssetsPath + "/Windows/Windows";

    //不管啥 应该查找依赖关系

    #region 加载依赖

    AssetBundle _manAB = AssetBundle.LoadFromFile(_manPath);
    //固定格式
    AssetBundleManifest manifest = _manAB.LoadAsset<AssetBundleManifest>("AssetBundleManifest");

    string[] dependencies = manifest.GetAllDependencies(ABName);
    //加载依赖

    if(dependencies.Length != 0)
    foreach (string s in dependencies)
    {
    //挨个加载依赖关系
    ManListAB.Add(LoadABByName(s)); // 存在内存中
    }

    #endregion


    //依赖加载完毕 圆柱和立方体
    AssetBundle _ab = AssetBundle.LoadFromFile(_abPath+ABName);
    GameObject copyObj = _ab.LoadAsset<GameObject>("Capsule");
    Instantiate(copyObj);
    //释放ab依赖的内存

    foreach (var v in ManListAB)
    {
    v.Unload(false);
    }

    _ab.Unload(false); // 不从场景里面剔除
    //true 场景剔除

    AssetBundle _ab01 = AssetBundle.LoadFromFile(_abPath+ABName); //_ab.Unload(false); 没有这句话会重复加载
    GameObject copyObj01 = _ab01.LoadAsset<GameObject>("Capsule");
    Instantiate(copyObj01,Vector3.one,Quaternion.identity);

    }

    // Update is called once per frame
    void Update () {

    }

    private AssetBundle LoadABByName(string name)
    {
    return AssetBundle.LoadFromFile(_abPath + name);
    }

    }

  • 相关阅读:
    安装LVS安装LVS和配置LVS的工作比较繁杂
    移动web开发研究
    10个顶级的CSS UI开源框架
    Jquery使用tbody编辑功能实现table输入计算功能
    【开源】Hawk-数据抓取工具:简明教程
    55个最实用大数据可视化分析工具
    Apache本地服务无法自启动问题解决
    网站10大致命SEO错误
    企业管理:名片的重要性
    开发人员应该知道的SEO
  • 原文地址:https://www.cnblogs.com/qipei/p/9885451.html
Copyright © 2011-2022 走看看