找回密码
 立即注册
楼主: 小米

[脚本] assetbundle 从远程读取.unity3d并在加载对应图片

[复制链接]
发表于 2013-5-10 11:08 | 显示全部楼层 |阅读模式
  1. public UITexture sprite;
复制代码

  1. WWW www = new WWW("http://121.199.16.23/atlas.unity3d");
  2.         yield return www;
  3.         Texture2D txt2d = new Texture2D(4, 4, TextureFormat.DXT1, false);
  4.         txt2d = www.assetBundle.mainAsset as Texture2D;
  5.         sprite.mainTexture = txt2d;
复制代码

评分

参与人数 1鲜花 +1 收起 理由
cxbsr + 1 很给力!

查看全部评分

发表于 2013-5-10 11:21 | 显示全部楼层
  1. void OnGUI(){
  2.  
  3. if(GUI.Button(new Rect(5,35,100,25) , "Load GameObject")){
  4.  
  5. StartCoroutine(LoadGameObject());
  6. }
  7. }
  8.  
  9. private IEnumerator LoadGameObject(){
  10.  
  11. // AssetBundle 檔案路徑
  12. string path = string.Format("file://{0}/../_AssetBunldes/{1}.assetBunldes" , Application.dataPath , "TestGameObject");
  13.  
  14. //  載入 AssetBundle
  15. WWW bundle = new WWW(path);
  16.  
  17. //等待載入完成
  18. yield return bundle;
  19.  
  20. //實例化 GameObject 並等待實作完成
  21. yield return Instantiate(bundle.assetBundle.mainAsset);
  22.  
  23. //卸載 AssetBundle
  24. bundle.assetBundle.Unload(false);
  25. }
复制代码
发表于 2013-6-3 22:40 | 显示全部楼层

不错 不错 不错{:soso__3922851084632044791_6:}
发表于 2013-12-22 17:10 | 显示全部楼层
请问帅哥大神,如何从web服务器下载资源呢?我只能下载本地。
发表于 2017-2-22 16:54 | 显示全部楼层
很不错
发表于 2017-2-22 17:17 | 显示全部楼层
难得一见的好帖
发表于 2017-2-22 17:41 | 显示全部楼层
说的非常好
发表于 2017-2-22 17:07 | 显示全部楼层
很好哦
发表于 2017-2-22 17:26 | 显示全部楼层
不错不错
发表于 2017-3-2 20:11 | 显示全部楼层
好帖就是要顶
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-5-4 22:56 , Processed in 0.092814 second(s), 26 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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