assetpostprocessor.onassignmaterialmodel 在模型指定的材质

2015-1-1 08:01| 发布者: 杨炎| 查看: 2417| 评论: 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


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.


class mymeshpostprocessor extends assetpostprocessor {

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


var materialpath = "assets/" + + ".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/" + + ".mat");

return material;