微软网站开发软件,如何创业做网站,做网站如何分类产品,网站建设话术分析unity导入资源的编辑器设置:
防止策划资源乱导入,资源导入需要的格式#xff0c;统一资源管理
AssetPostprocessor资源导入管线
AssetPostprocessor用于在资源导入时自动做一些设置#xff0c;比如当导入大量图片时#xff0c;自动设置图片的类型#xff0c;大小等。Ass…unity导入资源的编辑器设置:
防止策划资源乱导入,资源导入需要的格式统一资源管理
AssetPostprocessor资源导入管线
AssetPostprocessor用于在资源导入时自动做一些设置比如当导入大量图片时自动设置图片的类型大小等。AssetPostprocessor作为资源导入的管理器可以根据不同的资源类型在导入前、导入后做一些处理。 示例对图片纹理的设置需要放在OnPreprocessTexture方法中执行
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;public class TexturePostProcessor : AssetPostprocessor
{void OnPreprocessTexture(){TextureImporter textureImporter (TextureImporter)assetImporter;textureImporter.textureType TextureImporterType.Default;textureImporter.mipmapEnabled false;textureImporter.alphaIsTransparency true;textureImporter.npotScale TextureImporterNPOTScale.ToNearest;textureImporter.isReadable false;textureImporter.wrapMode TextureWrapMode.Clamp;int width 0, height 0;textureImporter.GetSourceTextureWidthAndHeight(out width, out height);Debug.LogErrorFormat(宽{0} 高{1}, width, height);if (assetPath.Contains(Assets)){Debug.LogError(assetPath);}}}一般常用的几个方法
OnPreprocessTexture在导入纹理贴图之前调用 OnPreprocessModel在导入模型之前调用 OnPreprocessAudio在导入音频之前调用
OnPostprocessTexture在导入纹理贴图之后调用 OnPostprocessModel在导入模型之后调用 OnPostprocessAudio在导入音频之后调用 OnPostprocessAllAssets所有资源的导入删除移动操作都会调用该方法