Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
AssetPostprocessor.OnPostprocessTexture 在导入纹理之后
# [AssetPostprocessor](AssetPostprocessor.html).OnPostprocessTexture 在导入纹理之后 function *OnPostprocessTexture* (*texture* : [Texture2D](../Texture2D/Texture2D.html)) : void *Description* 描述 Add this function in a subclass to get a notification when a texture has completed importing just before the texture is saved to disk. 在子类中加入这个函数,以便在纹理载入存入磁盘之前获得一个通知。 ``` // Postprocesses all textures that are placed in a folder // "invert color" to have their colors inverted. // 后处理文件夹内的全部纹理,完成颜色倒置. class InvertColor extends AssetPostprocessor { // Use this for initialization // 用这个初始化 function OnPostprocessTexture (texture : Texture2D ) { // Only post process textures if they are in a folder // "invert color" or a sub folder of it. // 如果它们在一个文件夹或其子文件夹,只能后处理纹理 // var lowerCaseAssetPath = assetPath.ToLower(); // if (lowerCaseAssetPath.IndexOf ("/invert color/") == -1) // return; for (var m=0;m < texture.mipmapCount;m++) { var c : Color [] = texture.GetPixels(m); for (var i=0;i < c.Length;i++) { c[i].r = 1 - c[i].r; c[i].g = 1 - c[i].g; c[i].b = 1 - c[i].b; } texture.SetPixels(c, m); } // Instead of setting pixels for each mip map levels, you can also // modify only the pixels in the highest mip level. And then simply use // texture.Apply(true); to generate lower mip levels. // 代替为mipmap各级设置像素, // 你也可以只修改最高层mipmap的像素点.之后用 // texture.Apply(true);生成低层mip } } ```
da
2022年5月14日 13:11
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码