纳金网

标题: 新版资源单个循环打包,修改资源名添加拓展名 [打印本页]

作者: may    时间: 2018-7-22 01:31
标题: 新版资源单个循环打包,修改资源名添加拓展名
  1. [MenuItem("Framework/SetABNameExtenAndBulidResource")]
  2.     static void SetBundleNameBuilResource()
  3.     {
  4.         Object[] selects = Selection.objects;
  5.         AssetBundleBuild[] buildMap = new AssetBundleBuild[selects.Length];
  6.         string[] paths = new string[selects.Length];
  7.         for(int i = 0;i < selects.Length; i++)
  8.         {
  9.             //AssetBundleBuild[] buildMap = new AssetBundleBuild[2];
  10.             paths[i] = AssetDatabase.GetAssetPath(selects[i]);

  11.             AssetImporter asset = AssetImporter.GetAtPath(paths[i]);
  12.             asset.assetBundleName = selects[i].name;
  13.             asset.assetBundleVariant = "<a  target="_blank" class="relatedlink">unity3d</a>";

  14.             buildMap[i].assetBundleName = selects[i].name;
  15.             buildMap[i].assetBundleVariant = "unity3d";

  16.             string[] enemyAssets = new string[1];
  17.             enemyAssets[0] = paths[i];
  18.             buildMap[i].assetNames = enemyAssets;
  19.         }
  20.         BuildPipeline.BuildAssetBundles("Assets/ABs",buildMap, BuildAssetBundleOptions.None,BuildTarget.WebGL);

  21.         AssetDatabase.Refresh();
  22.     }
复制代码
来自: 仅为年时





欢迎光临 纳金网 (http://rs.narkii.com/club/) Powered by Discuz! X2.5