找回密码
 立即注册
查看: 4126|回复: 82

[脚本] 动态加载模型贴图代码

[复制链接]
发表于 2012-11-26 18:45 | 显示全部楼层 |阅读模式

方法有两种
第一种: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]

Resource文件夹中一定有glass贴图  跟enemy物体及模型
第二种:AssetBundle
  1. function Start () {
  2. var www = new WWW ("http://192.168.1.106/myBundle.unity3d");
  3. yield www;
  4. // Get the designated main asset and instantiate it.
  5. Instantiate(www.assetBundle.mainAsset);
  6. }
复制代码
生成.unity3d的格式的 Assets-Build AseetsBundel
发表于 2012-11-28 19:00 | 显示全部楼层
真是好东西哦,希望能下载
发表于 2012-12-12 09:29 | 显示全部楼层
{:5_401:}GOOD!
发表于 2017-3-6 14:14 | 显示全部楼层
很不错
发表于 2017-3-6 14:16 | 显示全部楼层
楼主是超人
发表于 2017-3-6 13:32 | 显示全部楼层
真心顶
发表于 2017-3-6 13:32 | 显示全部楼层
很好哦
发表于 2017-3-6 13:29 | 显示全部楼层
不错不错
发表于 2017-4-6 08:51 | 显示全部楼层
楼主是超人
发表于 2017-4-6 08:38 | 显示全部楼层
好帖就是要顶
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-5-10 07:46 , Processed in 0.095196 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表