assetpostprocessor.onassignmaterialmodel 在模型指定的材质

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

摘要: assetpostprocessor.onassignmaterialmodel 在模型指定的材质functiononassignmaterialmodel(material:material,renderer:renderer) :materialdescription描述feeds a source material获取一个源材质。the returned ...

assetpostprocessor.onassignmaterialmodel 在模型指定的材质

functiononassignmaterialmodel(material:material,renderer:renderer) :material

description描述

feeds a source material

获取一个源材质。

the returned material will be assigned to the renderer. if you return null, unity will use its default material finding / generation method to assign a material. the sourcematerial is generated directly from the model before importing and will be destroyed immediately after onassignmaterial.

返回的材质将被赋于渲染器,如果返回null,unity将使用缺省材质查找/生成方法来分配材质。sourcematerial在模型导入并在销毁前,onassignmaterial之后直接从模型生成。

class mymeshpostprocessor extends assetpostprocessor {

function onassignmaterialmodel (material :material, renderer :renderer) :material

{

var materialpath = "assets/" + material.name + ".mat";

// find if there is a material at the material path

// turn this off to always regeneration materials

// 根据路径查找是否有材质,关闭后自动生成材质

if (assetdatabase.loadassetatpath(materialpath, typeof(material)))

returnassetdatabase.loadassetatpath(materialpath, typeof(material));

// create a new material asset using the specular shader

// but otherwise the default values from the model

// 用特定着色器创建新材质资源,否则使用默认值

material.shader =shader.find("specular");

assetdatabase.createasset(material, "assets/" + material.name + ".mat");

return material;

}

}

相关阅读

文章点评
相关文章