Unity之AssetPostprocessor学习一
来源:互联网 发布:南阳炳盛网络 编辑:程序博客网 时间:2024/05/16 06:16
using UnityEngine;using System.Collections;using UnityEditor;/// <summary>/// 在从外部导入texture、或者在导入之后对texture的自动处理/// </summary>public class ImportResDemo : AssetPostprocessor { /// <summary> /// 在导入纹理之后调用 /// </summary> /// <param name="texture"></param> public void OnPostprocessTexture(Texture2D texture) { TextureImporter textureImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter; if (textureImporter != null) { string AtlasName = new System.IO.DirectoryInfo(System.IO.Path.GetDirectoryName(assetPath)).Name; Debug.Log("name is: " + AtlasName); Debug.Log("textureType is: " + textureImporter.textureType); Debug.Log("maxTextureSize is: " + textureImporter.maxTextureSize); Debug.Log("textureFormat is: " + textureImporter.textureFormat); textureImporter.textureType = TextureImporterType.Sprite; textureImporter.spriteImportMode = SpriteImportMode.Single; textureImporter.spritePackingTag = AtlasName; textureImporter.mipmapEnabled = false; } } /// <summary> /// 在导入纹理之前调用 /// </summary> public void OnPreprocessTexture() { TextureImporter textureImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter; if (textureImporter != null) { textureImporter.textureType = TextureImporterType.Advanced; textureImporter.textureFormat = TextureImporterFormat.ARGB32; } } /// <summary> /// 移动、删除资源 /// </summary> /// <param name="importedAssets"></param> /// <param name="deletedAssets"></param> /// <param name="movedAssets"></param> /// <param name="movedFromAssetPaths"></param> private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { //当移动资源的时候 也就是重新导入资源 for (int i = 0; i < movedAssets.Length; i++) { Debug.Log("Reimported Asset: " + movedAssets[i]); } //删除资源 for (int i = 0; i < deletedAssets.Length;i++ ) { Debug.Log("Deleted Asset: " + deletedAssets[i]); } //移动资源 for (var i=0;i < movedAssets.Length;i++) { Debug.Log("Moved Asset: " + movedAssets[i] + " from: " + movedFromAssetPaths[i]); } }}
0 0
- Unity之AssetPostprocessor学习一
- AssetPostprocessor
- Unity之Quaternion学习一
- Unity之Mesh学习一
- unity学习之NGUI(一)
- 从零开始学习unity挖坑之路一
- Unity之Invoke、InvokeRepeating、StartCoroutine学习一
- Unity之UNet学习之旅(一)
- AssetPostprocessor 使用
- unity学习Socket(一)
- Unity学习一
- unity学习Socket(一)
- unity学习(一)
- Unity UGUI学习(一)
- unity shader 学习一
- unity学习笔记(一)
- Unity之EditorGUILayout-一
- Unity之Selection-一
- Remove Duplicates from Sorted Array II
- MarkDown入门小记
- android:descendantFocusability
- 以太网和PPPOE网络下MTU和MSS的关系
- Android平台Overlay机制
- Unity之AssetPostprocessor学习一
- Excel 列索引 转 列英文序号
- java中 0xff的意义
- 表的复杂查询-—多表查询
- js刷新页面方法大全
- datetime的时间处理逻辑
- 最小路径覆盖问题[网络流24题之3]
- Python包帮助文档
- 4.SUID、SGID、SBIT、chattr权限