方法有两种
第一种:Resources.Load
[code=javascript]// Assigns a texture named "Assets/Resources/glass" to a Plane.
function Start () {
var go = new GameObject.CreatePrimitive(PrimitiveType.Plane);
go.renderer.material.mainTexture = Resources.Load("glass");
}
// Instantiates a prefab at the path "Assets/Resources/enemy".
function Start () {
var instance : GameObject = Instantiate(Resources.Load("enemy"));
}[/code]