예제 #1
0
        /// <summary>
        /// 根据文件的File Path设置Asset的BundleName BundleName=Asset/XX/
        /// </summary>
        public static void SetAbNameByPath(string filePath)
        {
            string        assetPath = EPathHelper.AbsoluteToRelativePathWithAssets(filePath);
            AssetImporter importer  = AssetImporter.GetAtPath(assetPath);

            if (importer != null)
            {
                // 去掉Assets/ 和文件的后缀
                string str = EPathHelper.RemoveAssetsAndSuffixforPath(filePath);
                //Debug.AssertFormat(string.IsNullOrEmpty(importer.assetBundleName), "设置AssetBundle之前她已经有名字了:[{0}]", filePath);
                importer.assetBundleName = str + EAssetBundleConst.ASSETBUNDLE_EXTENSION;
                importer.SaveAndReimport();
            }
            else
            {
                UnityEngine.Debug.LogError("找不到对应的路径的资源:" + filePath);
            }
        }