public override void BeforeBuild() { base.BeforeBuild(); // Clear altas settings var resPath = Application.dataPath + "/" + ResConfig.UI_TEXTURE; var files = ResBuildUtility.GetFiles(resPath); foreach (var file in files) { if (file.EndsWith(".png") == false && file .EndsWith(".jpg") == false) { continue; } var assetPath = "Assets/" + file.ReplaceFirst(Application.dataPath + "/", ""); if (assetPath.StartsWith("Assets/" + ResConfig.UI_TEXTURE_RUNTIME)) { continue; } var textureImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter; ResTextureAutoConfigurer.ConfigureUITexture(textureImporter, true); } }
static void _AppendDependencies(AssetBundleBuild buildInfo, string name, List <AssetBundleBuild> buildInfos) { var dependencies = AssetDatabase.GetDependencies(name, true); foreach (var dependence in dependencies) { // Exclude assets not in Assets if (dependence.StartsWith("Assets") == false) { LogManager.Warning(string.Format( "asset({0}) depends on asset({1}) not in Assets!", name, dependence )); continue; } // Exclude scripts if (dependence.EndsWith(".cs") || dependence.EndsWith(".js")) { continue; } if (dependence.StartsWith("Assets/" + ResConfig.RES_ROOT)) { if (name != dependence && dependence.EndsWith(".shader") == false) { LogManager.Warning(string.Format( "asset({0}) depends on asset({1}) in Assets/Res, which should be prevented!", name, dependence )); } continue; } // Set atlas name if (dependence.StartsWith("Assets/" + ResConfig.UI_TEXTURE) && dependence.StartsWith("Assets/" + ResConfig.UI_TEXTURE_RUNTIME) == false) { var textureImporter = AssetImporter.GetAtPath(dependence) as TextureImporter; ResTextureAutoConfigurer.ConfigureUITexture(textureImporter); } var assetName = dependence; var assetBundleName = dependence; var dependenceRoot = dependence.ReplaceFirst("Assets", ResConfig.DEPENDENCIES_ROOT); if (ResConfig.IsFolderAsBundleName(dependence)) { var fileName = Path.GetFileName(dependence); assetBundleName = dependenceRoot.ReplaceLast("/" + fileName, "") + ResConfig.BUNDLE_EXTENSION; } else { assetBundleName = dependenceRoot + ResConfig.BUNDLE_EXTENSION; } var index = TryGetBuildInfo(buildInfos, assetBundleName); if (index == -1) { var dependenceBuildInfo = new AssetBundleBuild(); dependenceBuildInfo.assetNames = new string[] { assetName }; dependenceBuildInfo.assetBundleName = assetBundleName; buildInfos.Add(dependenceBuildInfo); _AppendDependencies(dependenceBuildInfo, assetName, buildInfos); } else { var dependenceBuildInfo = buildInfos[index]; var assetNames = dependenceBuildInfo.assetNames.ToList(); if (assetNames.Contains(assetName)) { continue; } assetNames.Add(assetName); dependenceBuildInfo.assetNames = assetNames.ToArray(); buildInfos[index] = dependenceBuildInfo; _AppendDependencies(dependenceBuildInfo, assetName, buildInfos); } } }