Why am I getting an error for PNG files in an iOS Bundle File?

I’m integrating Google Play Game Services into our app, and part of that process is including two files with the “.bundle” extension - GooglePlus.bundle and PlayGameServices.bundle. Two issues arise as a result of putting .bundle files into my Assets folder:

  1. Unity treats the .bundle files as folders (which I guess, under the hood, they are). Is there any way to force Unity to treat them as files? Unity will annoyingly try to import all the assets contained within the bundle, which is somewhat time consuming. I don’t need Unity to touch anything inside these bundles.

  2. For some, but not all, PNG files within the bundle, I get an error about not being able to read the file. Some PNGs show up in the inspector fine, but maybe 30-40 PNG files fill the editor log up with this error:

    Could not create texture from Assets/Editor/GooglePlayServices/Bundles/GooglePlus.bundle/gpp_sign_in_dark_button_disabled@2x.png: File could not be read

I’ve heard of this error occurring due to permissions issues or if the texture is larger than 4096x4096, but these are very small files, and I’ve checked the permissions of some other PNG files in the bundle that do import, and everything appears to be identical.

Any ideas as to why this is happening, or how I can fix? Thanks!

Apple software uses a proprietary PNG extension called CgBI which Unity (and other cross-platform productive software like GIMP) is unaware of.

http://iphonedevwiki.net/index.php/CgBI_file_format

Try taking one of the offending png files, opening it in a hex editor, you’ll see the letters CgBI in there if this is the reason.

You can work around it by following one of the methods described here:

http://www.jongware.com/pngdefry.html

  • Open the corrupted file in the OS X Preview app or any graphics program.
  • Make a dummy change and save the file
  • Undo your change and save it again

Now the error should disappear and you should see the import settings of the previously affected file.

Not sure if this will help you, but worth mentioning…

DXT texture compression is not supported by Unity iOS; use PVRTC formats instead, and Rectangular textures can not be compressed to PVRTC formats.

So not too sure about those bundles, what the files are for, and if they have any compression on them, but something to be aware of.