找回密碼
 注冊帳號

掃一掃,訪問微社區

assetpostprocessor.onassignmaterialmodel 在模型指定的材質

2015-1-1 08:01| 發布者: 楊炎| 查看: 2785| 評論: 0|原作者: 蠻牛|來自: unity3d腳本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;

}

}

相關閱讀

文章點評
相關文章
女校游泳队彩金