Unity3D 动态加载模型贴图方法
Posted on 2013 年 03 月 21 日 by U3d / Unity3D 基础教程/被围观 311 次
Unity3D 如何动态加载模型贴图?两种方法如下:
一.Resources.Load
Resource 文件夹中一定要有 glass 贴图,跟 enemy 物体及模型。
// 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"));
}
二.AssetBundle
生成 Unity3D 的格式的 Assets-Build AseetsBundel。