AssetPostprocessor.OnPostprocessModel 在导入模型之后
function OnPostprocessModel (root : GameObject) : void
Description描述
Add this function in a subclass to get a notification when a model has completed importing
在子类中加入这个函数,以便在模型载入之后获得一个通知。
just before a prefab is generated out of the game object hierarchy root is the root game object of the imported model.
在游戏物体脱离根层级之前生成一个预设,层次根是被导入的模型的根物体。
class MyModelPostprocessor extends AssetPostprocessor {
function OnPostprocessModel (g : GameObject ) {
Apply(g.transform);
}
// Add a mesh collider to each game object that contains collider in its name
// 根据名字添加一个mesh碰撞器在各个游戏物体上
function Apply (transform : Transform )
{
if (transform.name.ToLower().Contains("collider"))
{
transform.gameObject.AddComponent( MeshCollider );
}
// Recurse
// 循环
for (var child in transform)
Apply(child);
}
}
最后修改:2011年1月8日 Saturday 22:34