/// <summary> /// 设置texture的信息 /// </summary> /// <param name="size"></param> private static void SetTextureConfig(TextureConfig textureConfig, string srcPath) { TextureImporter import = AssetImporter.GetAtPath(srcPath) as TextureImporter; if (import != null) { //设置Texture的最大大小 if (textureConfig.m_TextureSize != -1) { import.maxTextureSize = textureConfig.m_TextureSize; } //设置Texture的类型 if (textureConfig.m_TextureType != EnumTools.GetException <TextureImporterType>()) { import.textureType = textureConfig.m_TextureType; } //设置Texture的WrapMode if (textureConfig.m_WrapMode != EnumTools.GetException <TextureWrapMode>()) { import.wrapMode = textureConfig.m_WrapMode; } //设置Texture的FilterMode if (textureConfig.m_FilterMode != EnumTools.GetException <FilterMode>()) { import.filterMode = textureConfig.m_FilterMode; } //待扩展 } }
public static void StartBuildBundle() { LogTools.Info("---------------------------------start-------------------------------------"); LogTools.Info("设置打包平台"); //设置打包平台 if (ProjectConfig.Instance.m_AssetBundleBuildTarget != EnumTools.GetException <BuildTarget>()) { buildTarget = ProjectConfig.Instance.m_AssetBundleBuildTarget; } LogTools.Info("清理资源:"); AssetsSetting.ClearResourcesDir(); //清空Resources目录 LogTools.Info("拷贝并导入资源"); srcPath = AssetsSetting.ImportAsset(srcPath); //将srcPath上的文件复制到Resources目录下,并且导入资源 LogTools.Info("设置资源"); AssetsSetting.ImporterSet(configJson, srcPath); //对资源进行各种参数修改和设置再次导入 LogTools.Info("清空AssetBundlesName"); ClearAssetBundlesName(); //清空AssetBundlesName LogTools.Info("设置AssetBundlesName"); PerpareToBuild(srcPath); //设置打包资源的assetBundleName LogTools.Info("开始打包"); StartToBuild(); //开始打包 LogTools.Info("导出资源"); string assetBundlePath = GlobalConstants.TempPath + "/" + FileTools.GetFileName(srcPath).ToLower() + ".ab"; AssetsSetting.MoveOutAsset(assetBundlePath, outPath); //将打包好的文件移动到输出目录 LogTools.Info("清空资源文件"); AssetsSetting.ClearResourcesDir(); //清空Resources目录 LogTools.Info("结束"); LogTools.Info("---------------------------------end-------------------------------------"); }
/// <summary> /// 设置资源的ModelImporterAnimationType /// </summary> private static void SetModelConfig(ModelConfig modelConfig, string srcPath) { ModelImporter import = AssetImporter.GetAtPath(srcPath) as ModelImporter; if (import != null) { //自动将新动画转为老动画 if (modelConfig.m_GenericToLegacy) { if (import.animationType == ModelImporterAnimationType.Generic) { import.animationType = ModelImporterAnimationType.Legacy; } } //设置模型的动画类型 if (modelConfig.m_ModelAnimationType != EnumTools.GetException <ModelImporterAnimationType>()) { import.animationType = modelConfig.m_ModelAnimationType; } //设置模型的材质模板 if (modelConfig.m_MaterialTypes != null && modelConfig.m_MaterialTypes.Length > 0) { foreach (var item in modelConfig.m_MaterialTypes) { Material material = Resources.Load("Materials/" + item.m_MaterialName) as Material; if (material != null) { MaterialTemplateTools.SetMaterialShaderProperty(material, item.m_TemplateName); } } } //判断模型上面的材质是否包含法线贴图,如果有法线贴图则找到贴图,并将贴图的类型改为NormalMap SetNormalMap(); //待扩展 } }