加载模型资源
来源:互联网 发布:深圳 原画 培训 知乎 编辑:程序博客网 时间:2024/04/27 18:22
转自:http://blog.csdn.net/dingxiaowei2013/article/details/13615497
2.从服务器端加载
这里我已经将资源模型加载到百度云盘上,然后获取一个url下载地址:(直接模型就是ok.unity3d格式的)
中间是搭建的sqlserver服务器和asp.net服务器:
- using UnityEngine;
- using System.Collections;
- using System.Text;
- public class NewBehaviourScript : MonoBehaviour
- {
- string s;
- private GameObject obj;
- private WWW www;
- private string url = @"http://192.168.1.6/plusFile/Test.aspx";
- private string url1 = @"http://114.92.247.6/xiaowei/ok.unity3d";
- void Start()
- {
- }
- private bool isCompleted = false;
- void Update()
- {
- if (www == null)
- {
- return;
- }
- if (!isCompleted && www.isDone)
- {
- print("Download completed");
- isCompleted = true;
- print("6");
- obj = GameObject.Instantiate(www.assetBundle.mainAsset) as GameObject;
- obj.transform.position = new Vector3(0, 1, 20);
- print("7");
- }
- }
- void OnGUI()
- {
- if (GUI.Button(new Rect(20, 20, 100, 40), "加载"))
- {
- StartCoroutine(getHtml(url));
- print("2");
- }
- }
- IEnumerator getHtml(string url)
- {
- print("3");
- WWW web = new WWW(url);
- yield return web;
- print("1");
- //Encoding e1 = new ASCIIEncoding();
- //this.s = e1.GetString(web.bytes);
- //print("web" + e1.GetString(web.bytes));
- this.s = web.text;
- StartCoroutine(getModel(s));
- }
- IEnumerator getModel(string str)
- {
- print("s:" + str);
- this.www = new WWW(str);
- yield return www;
- print("5");
- }
- }
同样的效果:
直接从网上获取资源:
- using UnityEngine;
- using System.Collections;
- public class NewBehaviourScript : MonoBehaviour {
- string url1 = @"http://114.92.247.6/xiaowei/ok.unity3d";
- GameObject obj;
- void Start () {
- }
- void Update () {
- }
- void OnGUI()
- {
- if (GUI.Button(new Rect(20, 20, 100, 40), "加载"))
- {
- StartCoroutine(getHtml(this.url1));
- print("2");
- }
- }
- IEnumerator getHtml(string url)
- {
- print("3");
- WWW web = new WWW(url);
- yield return web;
- obj = Instantiate(web.assetBundle.mainAsset) as GameObject;
- obj.transform.position = new Vector3(0,1,20);
- print("1");
- }
- }
0 0
- [unity3d]加载模型资源
- 加载模型资源
- Away3D加载模型中的资源映射问题
- AR如何动态加载模型资源并且将模型资源赋予某一个ImageTarget
- unity3d远程加载资源模型到本地并加载(一)打包资源
- unity3d远程加载资源模型到本地并加载(二)第一次加载资源后写到本地后从本地加载。
- flare 3D之加载模型资源见解
- 加载资源
- 加载资源
- 资源加载
- 加载模型
- 加载模型
- 概率主题模型资源
- 【Unity资源】(模型/人形)
- 【Unity资源】(模型/交通工具)
- 【Unity资源】(模型/道具)
- [资源分享]一些模型
- Spark资源模型
- ZOJ-2729
- Linux 身份切换工具
- WinForm解决多线程操作控件问题 线程间操作无效: 从不是创建控件的线程访问它"
- Linux Input子系统之第一篇(input_dev/input_handle/input_handler)
- Flex样式-ComboBox篇
- 加载模型资源
- 用crosstool-ng建立自己的ARM交叉编译工具链
- 设计模式初探-Prototype模式
- IOS开发基础之MVC模式
- Linux的计划任务
- Linux Input子系统第二篇之A/B(Slot)协议
- 首师大本科变专科 官方回应:学校也是受害方
- Android中关于PopupWindow的使用简介
- 基于ubuntu的armv7文件系统移植的权限问题