找回密码
 立即注册
楼主: scylove1989

[常见问题] unity3d 如何从网络加载obj模型并显示

[复制链接]
发表于 2013-10-17 22:39 | 显示全部楼层 |阅读模式
我是u3d菜鸟,请问unity3d 如何从网络加载obj模型并显示
发表于 2013-10-18 17:29 | 显示全部楼层
 楼主| 发表于 2013-10-21 09:51 | 显示全部楼层
本帖最后由 scylove1989 于 2013-10-21 09:52 编辑

使用服务器的url,代码如下
public class DownLoad3 : MonoBehaviour {
        public string url = "http://222.200.98.241:1082/"+"CubeTest.unity3d";
        
    public int version = 1;

        // Use this for initialization
        void Start () {
                string url2 = "file://"+Application.dataPath+"/CubeTest.unity3d";
                StartCoroutine(LoadBundle(url));
        }
        
        // Update is called once per frame
        void Update () {
        
        }
        
            public IEnumerator LoadBundle(string name){
        using(WWW www = WWW.LoadFromCacheOrDownload(name, version)){
            yield return www;
            AssetBundle assetBundle = www.assetBundle;
            GameObject gameObject = assetBundle.mainAsset as GameObject;
            Instantiate(gameObject );
            assetBundle.Unload(false);
        }
    }
}
使用url2就没有问题,但是使用url出现NullReferenceException异常,请问什么问题啊?
发表于 2017-3-12 13:52 | 显示全部楼层
顶顶多好
发表于 2017-3-12 13:49 | 显示全部楼层
真心顶
发表于 2017-3-12 14:14 | 显示全部楼层
难得一见的好帖
发表于 2017-3-12 14:29 | 显示全部楼层
很好哦
发表于 2017-3-12 14:31 | 显示全部楼层
LZ真是人才
发表于 2017-4-18 13:51 | 显示全部楼层
楼主是超人
发表于 2017-4-18 13:27 | 显示全部楼层
好帖就是要顶
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-4-28 04:54 , Processed in 0.189357 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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