zoukankan      html  css  js  c++  java
  • unity---------------------关于BuildAssetBundles的使用(打包)

    using UnityEditor;
    using UnityEngine;

    public class BuildAssetBundle
    {

    /// <summary>
    /// 点击后,所有设置了AssetBundle名称的资源会被 分单个打包出来
    /// </summary>
    [MenuItem("AssetBundle/Build (Single)")]
    static void Build_AssetBundle()
    {
    BuildPipeline.BuildAssetBundles(Application.dataPath + "/Test_AssetBundle", BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows);
    //刷新
    AssetDatabase.Refresh();
    }

    /// <summary>
    /// 选择的资源合在一起被打包出来
    /// </summary>
    [MenuItem("AssetBundle/Build (Collection)")]
    static void Build_AssetBundle_Collection()
    {
    AssetBundleBuild[] buildMap = new AssetBundleBuild[1];
    //打包出来的资源包名字
    buildMap[0].assetBundleName = "enemybundle";

    //在Project视图中,选择要打包的对象
    Object[] selects = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
    string[] enemyAsset = new string[selects.Length];
    for (int i = 0; i < selects.Length; i++)
    {
    //获得选择 对象的路径
    enemyAsset[i] = AssetDatabase.GetAssetPath(selects[i]);
    }
    buildMap[0].assetNames = enemyAsset;

    BuildPipeline.BuildAssetBundles(Application.dataPath + "/Test_AssetBundle", buildMap, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows);
    //刷新
    AssetDatabase.Refresh();
    }
    }

  • 相关阅读:
    撩课-Python-每天5道面试题-第8天
    声明提前、原型、静态方法的一些所得
    梳理ajax
    两数之和、整数反转、回文数
    node 基础API(fs)
    node 基础API(event)
    node 基础API(Buffer)
    node 基础API(path)
    node 调试技巧
    node process(进程) 几个常用属性
  • 原文地址:https://www.cnblogs.com/w-wfy/p/7725080.html
Copyright © 2011-2022 走看看