zl程序教程

您现在的位置是:首页 >  其他

当前栏目

[unity3d]加载模型资源

资源 模型 加载 Unity3D
2023-09-27 14:29:23 时间
}

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");




同样的效果:



直接从网上获取资源:

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");





5.0版本之后的AssetBundle资源的打包和解析加载(Unity3D) 这几天在研究AssetBundle资源打包盒解析加载,也踩过很多坑,参考过很多人的文章 发现很多人关于AssetBundle的文章不是API过时了不能用,就是有点乱 也不是有点乱,就是摸不着头脑,让人不能快速的get到这个东西如何使用 所以我特意在踩过坑之后把我这个学到的经验分享给大家。
Flutter中更快地加载您的图像资源 本文主要介绍在Flutter中更快地加载您的图像资源 我们可以将图像放在我们的资产文件夹中,但如何更快地加载它们?这是 Flutter 中的一个秘密函数,可以帮助我们做到这一点 — precacheImage()
在Flutter中更快地加载您的图像资源 我们可以将图像放在我们的资产文件夹中,但如何更快地加载它们?这是 Flutter 中的一个秘密函数,可以帮助我们做到这一点 — precacheImage()
本文提供全流程,中文翻译。 Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 —— 高分辨率用户请根据需求调整网页缩放比例)
本文提供全流程,中文翻译。 Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 —— 高分辨率用户请根据需求调整网页缩放比例)
蓬莱仙羽 麦子学院讲师,游戏蛮牛专栏作家,CSDN博客专家,热爱游戏开发,热爱Coding!