Unity导入处理:AssetPostprocessor

using System.Collections;
using UnityEditor;
public class MyEditor : AssetPostprocessor {
 
//模型导入之前调用
public void OnPreprocessModel()
{
Debug.Log ("OnPreprocessModel="+this.assetPath);
}
//模型导入之后调用
public void OnPostprocessModel(GameObject go)
{
Debug.Log ("OnPostprocessModel="+go.name);
}
//纹理导入之前调用,针对入到的纹理进行设置
public void OnPreprocessTexture()
{
Debug.Log ("OnPreProcessTexture="+this.assetPath);
TextureImporter impor = this.assetImporter as TextureImporter;
impor.textureFormat = TextureImporterFormat.ARGB32;
impor.maxTextureSize = 512;
impor.textureType = TextureImporterType.Advanced;
impor.mipmapEnabled = false;
 
}
public void OnPostprocessTexture(Texture2D tex)
{
Debug.Log ("OnPostProcessTexture="+this.assetPath);
}
 
 
public void OnPostprocessAudio(AudioClip clip)
{
 
}
public void OnPreprocessAudio()
{
AudioImporter audio = this.assetImporter as AudioImporter;
audio.format = AudioImporterFormat.Compressed;
}
//所有的资源的导入,删除,移动,都会调用此方法,注意,这个方法是static的
public static void OnPostprocessAllAssets(string[]importedAsset,string[] deletedAssets,string[] movedAssets,string[]movedFromAssetPaths)
{
Debug.Log ("OnPostprocessAllAssets");
foreach (string str in importedAsset) {
Debug.Log("importedAsset = "+str);
}
foreach (string str in deletedAssets) {
Debug.Log("deletedAssets = "+str);
}
foreach (string str in movedAssets) {
Debug.Log("movedAssets = "+str);
}
foreach (string str in movedFromAssetPaths) {
Debug.Log("movedFromAssetPaths = "+str);
}
}
 

猜你喜欢

转载自blog.csdn.net/qq_40833062/article/details/129276617