Unity3D之报错 - Instantiating a non-readable texture is not allowed!

报错:

Instantiating a non-readable ‘wall_plank‘ texture is not allowed! Please mark the texture readable in the inspector or don‘t instantiate it.

情景描述:

  加载AssetBundle时,把加载出来的所有Object对象都Instantiate实例化了,实例化过程中出现该错误。

解决方案:

  方案1:把要使用贴图文件(如*.Tga)的属性(如下图)设置Read/Write Enabled为true,对应的程序参数是TextureImporter.isReadable,即可以正常实例化。它决定了贴图的存放位置,设置为可读写,在移动平台中,会将其同时放在显存和内存中,导致内存占用增加一倍。

  方案2:资源加载时设置type

www.assetBundle.LoadAll(typeof(GameObject))

  方案3:遍历资源时添加判断

//通过字符串比较
"UnityEngine.GameObject".Equals(obj.GetType().ToString())
//通过类型比较
typeof(GameObject).IsInstanceOfType(obj)

参考:

【1】:http://blog.csdn.net/zzxiang1985/article/details/43339273  Unity+NGUI性能优化方法总结

【2】:http://www.u3dol.com/bbs/d/201406/6109

时间: 2024-12-25 14:38:58

Unity3D之报错 - Instantiating a non-readable texture is not allowed!的相关文章

iOS编译Unity3d文件报错 Permission denied

最近在尝试Unity3d的使用,毕竟Unity可以很好的编译出iOS代码,只用我们正常进行打包就好了. 这里遇到了个问题,分享一下. Archive快结束的时候,报了三个错误,类似于 /Users/sciyonSoft/Library/Developer/Xcode/DerivedData/Unity-iPhone-ghjhxtadvpljitbubdnbjvnxumck/Build/Intermediates/Unity-iPhone.build/Release-iphoneos/Unity-

babel版本兼容报错处理:Plugin/Preset files are not allowed to export objects

原文地址: https://www.cnblogs.com/jiebba/p/9618930.html 1.为什么会报错 ? 这里抱着错误是因为 babel 的版本冲突. 多是因为你的 babel 依赖包不兼容. 可以查看你的 package.json 的依赖列表 即有 babel 7.0 版本的( @babel/core , @babel/preset-react ) 也可命令查看 bebel-cli 的版本 ( babel -V ) 也有 babel 6.0 版本的 ( [email pro

axios跨域请求报错:Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.

在做项目时,用到axios,数据用post提交时,老是报错,错误提示为: 1 Access to XMLHttpRequest at 'http://127.0.0.1:3000/api/add' from origin 'http://localhost:8080' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers i

nginx检查报错:nginx: [emerg] "server" directive is not allowed here in

想检查一个配置文件是否正确,-c 指定之后发现有报错,如下: [[email protected]2:~# nginx -t -c /etc/nginx/conf.d/default.conf nginx: [emerg] "server" directive is not allowed here in /etc/nginx/conf.d/default.conf:1 nginx: configuration file /etc/nginx/conf.d/default.conf t

SVN无法显示资源历史记录,报错Item is not readable

Eclipse svn插件或者软件查看版本历史时Item is not readable,在eclipse会弹出错误框 配置目录权限时如: [/] zchuanzhao=rw 结果组用户分别在根目录下可以正常show log,而在其子目录中 show log都会提示 Item is not readable. 在svnserve.conf 文件中,默认下是anon-access = read,设置成 anon-access = none

解决Xcode6.0.1编译Unity3D工程报错

错误信息大概如下 Undefined symbols for architecture i386: "_clock$UNIX2003",.....等 大概就是引用了一个链接库出错了. 解决办法如下: 打开OC工程里的Main.mm 加入下面代码 #include <time.h> extern "C" { clock_t clock$UNIX2003(void) { return clock(); } }

【Unity3D】生成工程报错解决—UnityEditor.HostView:OnGUI() Error building Player: Couldn&#39;t build player because of unsupported data on target platform.

错误 错误1:An asset is marked as dont save, but is included in the build: unityEditor.HostView:OnGUI() 错误2:Building - Failed to write file: sharedassets0.assetsUnityEditor.HostView:OnGUI() 错误3:Error building Player: Couldn't build player because of unsup

Unity3D中UGUI使用ScrollBar之后保存,工程启动报错原因跟踪

笔者不久前将Unity3D版本更新为4.6.2之后.在使用新UI的时候发现关闭项目之后经常再次打开项目会出现一对的报错. 找了一圈,发现是ScrollBar控件出现了BUG.整个空间的滑块消失了. 在控制台输出了 m_TransformInfo.worldAABB.IsValid() ... IsFinite(outDistanceForSort) IsFinite(outDistanceAlongView) ... IsFinite(outDistanceAlongView) UnityEdi

Unity3D 程序打包报错(程序是连接数据库进行处理的)

打包这个Unity3D的程序时出现错误(程序是由XML数据改成连接数据库): ArgumentException: The Assembly System.Configuration is referenced by System.Data. But the dll is not allowed to be included or could not be found. UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (Syst