位置: 编程技术 - 正文

Unity_从服务器下载资源,加载到手机——很慢(unity服务器端)

编辑:rootadmin
using UnityEngine;using System.Collections;using System.IO;using System.Collections.Generic;using System;public class Text : MonoBehaviour { public GameObject cube; public string recName=""; public string mUrl=""; private string realUrl; void Start () { realUrl = mUrl &#; recName; StartCoroutine(loadasset(realUrl)); } //写入模型到本地 IEnumerator loadasset(string url) { WWW w = new WWW(url); yield return w; if (w.isDone) { byte[] model = w.bytes; int length = model.Length; CreateModelFile(Application.persistentDataPath, model,length); } } void CreateModelFile(string path, byte[] info, int length) { Stream sw; FileInfo t = new FileInfo(path &#; "//" &#; recName); if (!t.Exists) { Debug.Log ("文件不存在"); sw = t.Create(); } else { Debug.Log ("文件存在"); return; } sw.Write(info, 0, length); sw.Close(); sw.Dispose(); } //读取模型文件 IEnumerator LoadModelFromLocal( ) { recName = "sphere"; WWW w = new WWW(" ; yield return w; GameObject obj = Instantiate (w.assetBundle.LoadAsset(recName,typeof(GameObject))) as GameObject; obj.transform.position = cube.transform.position; /*while (w.isDone==false) yield return null; AssetBundleRequest req = w.assetBundle.LoadAssetAsync (recName); while(req.isDone==false) yield return null;*/ /*GameObject go = (GameObject)Instantiate (req.asset); go.transform.position = cube.transform.position;*/ } void OnGUI() { if (GUILayout.Button ( Application.persistentDataPath &#;"/" &#; recName)) { StartCoroutine(LoadModelFromLocal( )); } string per = Application.persistentDataPath; GUI.Label (new Rect (, , , ), per); } }

推荐整理分享Unity_从服务器下载资源,加载到手机——很慢(unity服务器端),希望有所帮助,仅作参考,欢迎阅读内容。

Unity_从服务器下载资源,加载到手机——很慢(unity服务器端)

文章相关热门搜索词:unity访问服务器数据库,unity获取服务器数据,unity游戏服务器教程,unity部署到服务器,unity服务器端,unity从服务器下载ab包,unity服务器端,unity从服务器下载ab包,内容如对您有帮助,希望把文章链接给更多的朋友!

Unity 编写类似神庙逃亡手势 1、首先我们先定义一个枚举,用来表示手势滑动的四个方向:spanstyle=font-size:px;publicenumTouchDirection{Unkown,Left,Right,Up,Down}/span2、定义类:TouchInputspanstyle=f

一起来学u3d之圣典.2 一起来学u3d之圣典.2废话不多说,一针见血,go!一起来看API其中不懂的大家互相帮助哈英文部分版权属©Unity公司所有,中文部分©Unity圣典版权所有。

Unity Shader——Writing Surface Shaders 从今天起,开始翻译Unity关于shader的官方文档。翻译水平比较一般,目的主要是通过翻译来提升对shader的见解,也让其他人更容易的了解shader。以下开始

本文链接地址:https://www.jiuchutong.com/biancheng/377214.html 转载请保留说明!

上一篇:Unity 物理引擎实现匀速圆周运动(unity物理引擎原理)

下一篇:Unity 编写类似神庙逃亡手势(unity 替代)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络