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

因为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系统中有的字体,然后编译也成功了。



原文地址:https://www.cnblogs.com/wgwyanfs/p/6956205.html