言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

AssetPostprocessor.OnPostprocessModel(GameObject)

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

この関数をサブクラスに追加してモデルのインポートが完了したときに通知を取得します

This lets you modify the imported Game Object, Meshes, AnimationClips referenced by it. Please note that the GameObjects, AnimationClips and Meshes only exist during the import and will be destroyed immediately afterwards. この関数は最終のプレハブが作成される前、そしてディスクに書き込みされる前に呼び出しされるため生成されたゲームオブジェクトおよびコンポーネントに対して完全に制御ができます。 Any references to game objects or meshes will become invalid after the import has been completed. Thus it is not possible to create a new prefab in a different file from OnPostprocessModel that references meshes in the imported fbx file. /root/ is the root game object of the imported model.

	// Adds a mesh collider to each game object that contains collider in its name		

	class ColliderOnName extends AssetPostprocessor {
		function OnPostprocessModel (g : GameObject) {
			Apply(g.transform);
		}

		function Apply (transform : Transform) {
			if (transform.name.ToLower().Contains("collider")) 
				transform.gameObject.AddComponent(MeshCollider);		
			// Recurse
			for (var child in transform)
				Apply(child);
		}
	}