博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
NGUI在5.3打包失败问题
阅读量:7029 次
发布时间:2019-06-28

本文共 1850 字,大约阅读时间需要 6 分钟。

一、NGUI版本

NGUI是很好用的Unity UI插件。 

当前使用版本NGUI Next-Gen UI v3.9.7 (Feb 10, 2016)和NGUI Next-Gen UI 3.9.0两个版本 
一开始觉得新版本估计有新功能和更稳定些,就是用来新版本。

报错了!!打包失败了!!真是莫名其妙!!

报错的如下:《为方便搜索写一遍》 

1.An asset is marked with HideFlags.DontSave but is included in the build” 
Asset:‘Libray/unity editor resource’ 
2.building-Failed to write file:sharedassets0.assets. 
3.Error building Player:couldn’t build player because of unsuported data on target platform.

这里写图片描述

二、新旧版本

使用了新版本有问题,一开始说是网上都说是要使用NGUI的字体,然后才可以正确打包。 

要说的是:这里是可以在编辑器下运行的,就是打包有问题。所以就怀疑版本问题。 
在工程里修改后,然并卵。

但是重点是:要是直接用Unity5.3打包导入的3.9.7,真的一点问题也没有,也是可以打包的。 

故此,很可能是3.9.7里面的代码与我们工程代码在打包时有冲突的地方。

怎么办?这就是个坑啊!! 

各种办法都试试,最终结果还是要回退到3.9.0版本。所以程序一字不易的就可以正常打包了。

逐个对比了所有脚本文件: 

如下:

新版本:#if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2            Application.LoadLevel(levelName);#else            UnityEngine.SceneManagement.SceneManager.LoadScene(levelName);#endif } 说明还是与时俱进的。 在NGUITool.cs里面: #if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 return te.content.text; #else return te.text; #endif } set { TextEditor te = new TextEditor(); #if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 te.content = new GUIContent(value); #else te.text = value; #endif te.OnFocus(); te.Copy(); }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

说明5.3没有添上啊!!这个有问题么?待定。

差别较大的,应该还是字体了。

UILabel.cs文件里:旧版本中:#if !UNITY_3_5#define DYNAMIC_FONT#endif
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5

旧版本中的DYNAMIC_FONT在新版本中都没有了。 

新版本中删掉了,可能新版本中使用trueType的字体,所以干掉了宏定义。不理解。

没有做进一步的。

变化大的有: 

UIBasicSpriteEditor.cs 
UIToggleInspector.cs 
UIPopupList.cs 
UIRect.cs 
NUITool.cs 
UILabel.cs 
UICamera.cs(修改宏定义较多)

三、最后

对项目来说,问题是解决了,就是要替换版本,使用3.9.0版本。 

若这样,就有两种可能,NGUI的3.9.7版本与工程代码在打包时或打包设置这方面有冲突或bug. 
还有就是我们的使用方法不对。 
那为啥3.9.0就可以一字不易的,只导入包就可以了呢?? 
真是扰人啊!!!

只能盼高人了。

就这样!!! 

你可能感兴趣的文章