Unity3d使用www类加载网络图片出现红色问号解决办法

本文探讨了Unity中使用WWW加载网络图片时遇到红色问号的问题,分析可能原因包括图片过大、格式不正确等,并提供了一种有效的解决方案:通过检查WWW.bytes数组长度来判断图片是否成功下载。

项目里使用www加载网络图片,今天加载出来一个红色问号,出现的原因可能是:图片过大、格式问题、资源损坏、网络延迟高等等原因,解决方案也很多。但是现在的情况是,www.error或者www.isdone拦不住出现红色的问题,换句话说就是你看到图片之前不知道这次下载是不是成功了。基于以上问题我的解决办法是判断www.bytes的数组,目前我的项目有效,当出现红色问号的时候www.bytes.length = 0,其实也就是没下载下来。

IEnumerator LoadTexture(string url)

{

      WWW www = new WWW(url);

      yield return www;

    if(www.error == null && www.bytes.length != 0)

  {

     "成功"

  }else{

    “失败”

}

行 277185: 11-11 18:25:47.324061 16995 17231 W Unity : DontDestroyOnLoad only works for root GameObjects or components on root GameObjects. 行 277561: 11-11 18:25:47.914532 16995 17710 E Unity : -------- GLSL link error: The number of vertex shader storage blocks (1) is greater than the maximum number allowed (0). 行 277936: 11-11 18:25:48.832760 16995 17711 W Unity : The referenced script (CustomCubeMip) on this Behaviour is missing! 行 277943: 11-11 18:25:48.841515 16995 17711 W Unity : The referenced script on this Behaviour (Game Object '!ftraceLightmaps') is missing! 行 277946: 11-11 18:25:48.841781 16995 17711 W Unity : The referenced script on this Behaviour (Game Object 'combinecube') is missing! 行 277978: 11-11 18:25:48.901343 16995 17231 W Unity : Particle System is trying to spawn on a mesh with zero surface area 行 278701: 11-11 18:25:50.442267 16995 17231 I Unity : Default clip could not be found in attached animations list. 行 279609: 11-11 18:25:52.305336 16995 17231 I Unity : ALog2019-2.01.0052.07-eLogBattle-jishuai-[Next2025] strategyID 4 not find in Next2025Config 行 279832: 11-11 18:25:52.836090 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 279854: 11-11 18:25:52.837523 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 279876: 11-11 18:25:52.839913 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 279899: 11-11 18:25:52.841155 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 279922: 11-11 18:25:52.843595 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 279944: 11-11 18:25:52.844802 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 279967: 11-11 18:25:52.847697 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 279991: 11-11 18:25:52.848928 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280014: 11-11 18:25:52.851305 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280036: 11-11 18:25:52.852514 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280059: 11-11 18:25:52.854913 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280082: 11-11 18:25:52.856141 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280106: 11-11 18:25:52.860700 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280128: 11-11 18:25:52.861933 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280151: 11-11 18:25:52.864219 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280173: 11-11 18:25:52.865444 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280196: 11-11 18:25:52.867845 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280218: 11-11 18:25:52.869131 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280241: 11-11 18:25:52.871468 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280263: 11-11 18:25:52.872769 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280288: 11-11 18:25:52.875152 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280310: 11-11 18:25:52.876290 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280333: 11-11 18:25:52.878866 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280355: 11-11 18:25:52.879882 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280380: 11-11 18:25:52.884141 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280403: 11-11 18:25:52.885338 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280426: 11-11 18:25:52.887457 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280449: 11-11 18:25:52.888444 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280472: 11-11 18:25:52.890603 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280494: 11-11 18:25:52.891612 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280516: 11-11 18:25:52.894305 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280542: 11-11 18:25:52.900280 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280564: 11-11 18:25:52.902652 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280586: 11-11 18:25:52.903663 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280609: 11-11 18:25:52.905926 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_BattleGround.unity3d 行 280631: 11-11 18:25:52.907128 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_BattleGround.unity3d'. 行 280667: 11-11 18:25:52.942162 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_HeadIcon02.unity3d 行 280691: 11-11 18:25:52.943137 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_HeadIcon02.unity3d'. 行 280715: 11-11 18:25:52.944505 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_HeadIcon02.unity3d 行 280739: 11-11 18:25:52.945491 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_HeadIcon02.unity3d'. 行 280764: 11-11 18:25:52.946874 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_HeadIcon02.unity3d 行 280788: 11-11 18:25:52.947936 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_HeadIcon02.unity3d'. 行 280812: 11-11 18:25:52.949334 16995 17231 E Unity : Unable to open archive file: UI/android/Atlas_HeadIcon02.unity3d 行 280835: 11-11 18:25:52.950378 16995 17231 E Unity : Failed to read data for the AssetBundle 'Atlas_HeadIcon02.unity3d'.
最新发布
11-14
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值