unity中从Resources下unity 读取excel较大的资源会卡,有解决办法么

unity中运用Resources.Load的方法 - CSDN博客
unity中运用Resources.Load的方法
问:unity中运用Resources.Load的方法?
答:Resources.Load是unity本地动态加载资本所用的方法,也即是你想动态加载的时分才用到它,比方枪弹,特效,某些实时替换的图像什么的,主张此文件夹不要放太多东西,在打包的时分,它会独自把里边的一切东西都会集打包到一同,不论里边有没有你用的东西,所以大多数资本应该是自个建文件放置
1、unity实时替换的物体即是依据环境条件的不一样而取用不一样的资本,比方滚球游戏,木球成为铁球,换一张贴图就可以了,这张图就放到Resources里边,由于球随时都可能会成为木球或许铁球,这是实时的,详细看游戏要求,灵活运用.
2、unity音效,预制体,需求改换的纹路可以依据状况放到Resources,模型图像,NGUI的各资本都不需求放到Resources,自个创立文件夹,自个收拾放置,这些不需求实时变化。
在上面说到的用法是我的一些经历,实践中不知道会不会其它变化,但可以先参考我以上的一些操作方法。
兄弟连IT教育与全球移动游戏联盟(GMGC)共同设立中国首家基于高端游戏开发的兄弟连&GMGC!高薪就业,就学手游开发,详情咨询官网客服:
高薪就业,就学unity手游开发!详情咨询QQ
本文已收录于以下专栏:
相关文章推荐
初步整理并且学习unity3d资源加载方法,预计用时两天完成入门学习Unity3d常用两种加载资源方案:Resources.Load和AssetBundle
Resources.Load就是从一...
1.index.html
test load()
$(function() {
$(&input:eq(0)&).click(function() {
Unity3D 的动态加载机制,本地加载和远端加载以及简单的内存管理
反编译unity project资源文件,包括ios,android,pc等,仅供学习使用!
工具(任选其一)
1.disunity
编译版地址:/ata4/...
大家可能都知道在Unity3D中如何实现动态加载资源的方法,就是把资源放在Resources目录下,使用Resources.Load方法即可动态加载资源。但将资源放在Resources目录下有一个问题...
There are a number of scenarios where you want to include some kind of asset in your finished game t...
这次过程太过艰辛,在网上搜了很多,然而一个能用的都没有,于是自己硬生生的试了出来,就讲结论吧。
要做的事情是用脚本读取音频文件,其实读取音频文件用GUI是非常简单的,可是,HRTF的数据库动...
加载资源Resources.Load(),卸载资源分三种情况:非GameObject资源,GameObject资源及其克隆体
The AssetBundle is only provided by Pro version, so I think i need to Resources c...
他的最新文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)  初步整理并且学习资源加载方法,预计用时两天完成入门学习Unity3d常用两种加载资源方案:和
Resources.Load就是从一个缺省打进程序包里的里加载资源而一般文件需要你自己创建,运行时动态加载,
可以指定路径和来源的。其实场景里所有静态的对象也有这么一个加载过程,只是后台替你自动完成
一::使用这种方式加载资源,首先需要下目录下创建一个名为的文件夹,这个命名是规定的方式,然后把资源文件放进去,
当然也可以在中再创建子文件夹,当然在代码加载时需要添加相应的资源路径,下面是一个简,两个预设,和,
其中放在中的中,而放在跟目录下,下面分别实现Resources.Load资源的加载
using UnityE
using System.C
public class LoadResDemo : MonoBehaviour {
private string cubePath = "Prebs/MyCubePreb";
private string spherePath = "MySpherePreb";
void Start () {
//把资源加载到内存中
cubePreb = Resources.Load(cubePath, typeof(GameObject));
//用加载得到的资源对象,实例化游戏对象,实现游戏物体的动态加载
GameObject cube = Instantiate(cubePreb) as GameO
//以下同理实现Sphere的动态实例化
//把资源加载到内存中
Object spherePreb = Resources.Load(spherePath, typeof(GameObject));
//用加载得到的资源对象,实例化游戏对象,实现游戏物体的动态加载
GameObject sphere = Instantiate(spherePreb) as GameO
void Update () {
  将上面的脚本附加到某个游戏对象上,在运行游戏时就可以看到场景中动态创建的上面的游戏对象了
上面是第一种使用Resources.Load()的方式动态加载游戏对象的,然而在项目中更长用的却是第二种使用AssetBundle的方式动态加载游戏对象。
使用AssetBundle打包预设或者场景可以将与其相关的所有资源打包,这样很好地解决资源的依赖问题,使得我们可以方便的加载GameObject
首先需要打包资源:
using UnityE
using System.C
using UnityE
using System.IO;
public class AesstBundleTest : MonoBehaviour {
[MenuItem("Custom Bundle/Create Bundel Main")]
public static void creatBundleMain()
//获取选择的对象的路径
Object[] os = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
bool isExist = Directory.Exists(Application.dataPath + "/StreamingAssets");
if (!isExist)
Directory.CreateDirectory(Application.dataPath + "/StreamingAssets");
foreach (Object o in os)
string sourcePath = AssetDatabase.GetAssetPath(o);
string targetPath = Application.dataPath + "/StreamingAssets/" + o.name + ".assetbundle";
if (BuildPipeline.BuildAssetBundle(o, null, targetPath, BuildAssetBundleOptions.CollectDependencies))
print("create bundle cuccess!");
print("failure happen");
AssetDatabase.Refresh();
[MenuItem("Custom Bundle/Create Bundle All")]
public static void CreateBundleAll()
bool isExist = Directory.Exists(Application.dataPath + "/StreamingAssets");
if (!isExist)
Directory.CreateDirectory(Application.dataPath + "/StreamingAssets");
Object[] os = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
if (os == null || os.Length == 0)
string targetPath = Application.dataPath + "/StreamingAssets/" + "All.assetbundle";
if (BuildPipeline.BuildAssetBundle(null, os, targetPath, BuildAssetBundleOptions.CollectDependencies))
print("create bundle all cuccess");
print("failure happen");
AssetDatabase.Refresh();
把上面的代码放在Editor中,在菜单栏中就可以看见自定的菜单项,选中需要打包的预设,就可以把对应的预设打包并输出到StreamAssets中了
然后是动态加载资源:
using UnityE
using System.C
public class LoadBundleTest : MonoBehaviour {
//不同平台下StreamingAssets的路径是不同的,这里需要注意一下。
public static readonly string PathURL =
#if UNITY_ANDROID
"jar:file://" + Application.dataPath + "!/assets/";
#elif UNITY_IPHONE
Application.dataPath + "/Raw/";
#elif UNITY_STANDALONE_WIN || UNITY_EDITOR
"file://" + Application.dataPath + "/StreamingAssets/";
// Update is called once per frame
void Update () {
void OnGUI()
if (GUILayout.Button("Load Bundle Main"))
string path_shpere = PathURL + "MySpherePreb.assetbundle";
StartCoroutine(loadBundleMain(path_shpere));
string path_cube = PathURL + "MyCubePreb.assetbundle";
StartCoroutine(loadBundleMain(path_cube));
print(path_cube);
if (GUILayout.Button("Load Bundle All"))
StartCoroutine(loadBundleAll(PathURL + "All.assetbundle"));
private IEnumerator loadBundleMain(string path)
WWW bundle = new WWW(path);
Instantiate(bundle.assetBundle.mainAsset);
bundle.assetBundle.Unload(false);
yield return 1;
private IEnumerator loadBundleAll(string path)
WWW bundle = new WWW(path);
yield return
Instantiate(bundle.assetBundle.Load("MyCubePreb"));
Instantiate(bundle.assetBundle.Load("MySpherePreb"));
yield return 1;
阅读(...) 评论()}

我要回帖

更多关于 unity 读取excel 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信