assetpostprocessor.onpostprocesstexture 在导入纹理之后

2015-1-1 07:21| 发布者: 杨炎| 查看: 2476| 评论: 0|原作者: 蛮牛|来自: yzc88亚洲城脚本manual

摘要: assetpostprocessor.onpostprocesstexture 在导入纹理之后functiononpostprocesstexture(texture:texture2d) : voiddescription描述add this function in a subclass to get a notification when a texture has comp ...

assetpostprocessor.onpostprocesstexture导入纹理之后

functiononpostprocesstexture(texture:texture2d) : 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 script/") == -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

}

}

相关阅读

文章点评
相关文章