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

    }

  • 相关阅读:
    Too many fields describes: 101 解决方法
    [Salesforce] 时区 问题
    [Salesforce] related list remove edit link
    apex获取页面中的url中的参数
    定义常量 map
    FIELD_CUSTOM_VALIDATION_EXCEPTION
    Salesforce message 里 放 link
    WinForm上显示gif动画[转]
    C/C++ Handle data types[转]
    Temporary Post Used For Theme Detection (b4e6dd688472447db6af8590aee16d59 3bfe001a32de4114a6b44005b770f6d7)
  • 原文地址:https://www.cnblogs.com/qipei/p/9885451.html
Copyright © 2011-2022 走看看