现在的位置: 首页 > 综合 > 正文

编译时,遇到Couldn’t build player because of unsupported data on target platform的解决方案

2016年12月11日 ⁄ 综合 ⁄ 共 1389字 ⁄ 字号 评论关闭

由于pc机子太老了,所以一直都是在mac下面写unity程序,然后在拷贝到pc上生成apk到手机上,今天在移植的时候就出现了问题,在mac机子和pc机子上都运行的好好的,但编译到手机上的时候出现了如下的错误:


Couldn't build player because of unsupported data on target platform

Building - Failed to write file: sharedassets0.assets
UnityEditor.HostView:OnGUI()

An
asset is marked as dont save, but is included in the build:


熟话说外事不决用google,结果在如下的一个网址上找到了答案:

http://forum.unity3d.com/threads/209013-quot-Couldn-t-build-player-because-of-unsupported-data-on-target-platform-quot

有人遇到了同样的问题。


看如何解决的哈:

“ The
error came with NGUI. 
I use a label with "dynamic" font. You have to use bitmap.”

我按照这个思路回去检查了一遍,果然发现我有个ngui的Label用的是dynamic字体,我将其改为bitmap之后,编译就通过了。


至于原因,后面有个哥们给出了答案:

You don't have to use bitmap but you must make sure that you reference a ttf file
that is actually in the project. Annoyingly it shows a selector for ones that aren't there or are hidden.


再去看ngui官网上关于dynamic的字体解释

All labels require a Font to
work with. This font can be 
Dynamic (directly
referencing a Unity Font), or it can be a 
Bitmap font
-- a font embedded within an Atlas. Dynamic fonts are more robust as they don't require you to pre-generate your glyphs before hand, but Bitmap fonts can be drawn within the same draw call as the rest of your atlas, and can be decorated nicely in an image
editing tool such as Photoshop.


结合上面的两点可以推测出原因,造成之前那个问题的原因是我们引用了一个字体文件,但这个字体文件却并没有包含在我当前的Project中,所以导致了那个报错。

我于是去看了一下,我的这个问题是我在mac下面的时候引用了一个字体,但这个字体在windows下面不存在,所以报错了。

不过好像那个哥们说错了,并不一定我们使用dynamic时,那个字体一定要在我们的project目录中,只要能在当时编译的系统中存在那个字体就行,我后来又试了一下,使用dynamic字体引用了一个windows系统中有的字体,然后编译也成功了。


抱歉!评论已关闭.