Search Unity

How to retain texture import settings when switching build platforms

Discussion in 'iOS and tvOS' started by theFongz, Sep 28, 2018.

  1. theFongz

    theFongz

    Joined:
    Jul 9, 2014
    Posts:
    10
    Hi, I have a Unity project which has been developed for Android and I want to build it out onto iOS.

    My problem is, whenever I perform the conversion build, all the texture files get re-imported using a different format. This causes big performance problems and indeed some functional problems. As a result, I need to spend a couple of hours each time finding every texture file and modifying its import properties.

    Is there any workflow or tool that can be used to retain the import settings?

    This is my current conversion workflow:

    1. On my PC with the Android build, most of my textures are using ECT2 8 bit (alpha) or ECT2 4 bit (without alpha) format.
    2. Copy the project folder over to my Mac and open the project in Unity there.
    3. Unity complains about the Android build platform and reimports everything to suit the Mac platform.
    4. Once that is complete, I go to Build Settings and rebuild for the iOS platform. This triggers another reimport.
    5. Once that is complete, all of the textures have changed to PVRTC format.
    6. So I then have to pick through all the textures I can find, tick "Override for iOS" and set the format back to ECT2.
    There has got to be a better way of doing this. Any suggestions would be appreciated.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    What problems are you seeing? PVRTC offers identical or higher compression for often better quality than ETC or ETC2 (depending on the content). 24 bit content can be stored at a 6:1 (same as ETC) or a 12:1 compression ratio, and 32 bit content can be stored at 8:1 or 16:1, where ETC2 can only do 4:1. Decompression is done on the hardware at the same rate per byte, so the only difference is file size which PVRTC matches or beats.

    In short, Unity switches to PVRTC on iOS because it is the superior image format in terms of performance, so I'm not sure why you're seeing performance problems with it. The only thing I can think of is I believe ETC has a max texture size of 2048x2048 which PVRTC does not have. If you're importing very large images, they may be showing up at much larger sizes on iOS vs. Android as they may not be getting scaled down as much.

    Functionality problems I can see if you're doing a lot of hard edged pixel art. PVRTC isn't always as good at that content, it's more intended for photo-like content.


    If you still want to change the textures to use ETC or ETC2 on iOS, what you're doing is roughly the correct route. If you're using .meta files, you could look at how they differ on your Mac after modifying the format and copy those settings back onto your PC so you don't have to do it again. I also seem to remember it's possible to install the iOS stuff on the PC, which won't let you build but will let you set the texture properties from the PC editor.
     
    theFongz likes this.
  3. theFongz

    theFongz

    Joined:
    Jul 9, 2014
    Posts:
    10
    Thanks a lot for the response, bgolus.

    Regarding the performance problems, I checked again and I think the problem is that it's not using PVRTC effectively.

    As per the screenshot below, the textures are not a power of two (they are animation sprites for my hero character) so it looks like it might be multiplying the whole thing by four to make it work.

    upload_2018-10-14_17-9-33.png

    I checked and my POT textures do come in at half the size with PVRTC so I can see what you mean there though.

    Regarding the functional problems, the only one I'm really seeing is the following exception when I try to call GetPixel in a RayCastMask script:

    Unsupported texture format - needs to be ARGB32, RGBA32, BGRA32, RGB24, Alpha8, RGBAFloat, RGBAHalf or one of supported compressed formats.
    UnityEngine.Texture2D:GetPixel(Int32, Int32)

    Luckily I'm only making use of this RayCastMask script with two textures so I can just manually remember to switch them over every time I guess. But a lot of my spritework is NPOT so the performance issue is a big headache.

    The overall impression I get is that PVRTC is not suitable to my current requirements and I was hoping for some way to tell Unity to use ECT2 as standard during the conversion process instead of PVRTC.

    If there's no way to do that then I guess I can go the route of manually editing the .meta files. It would be nice if I could keep settings for both android and iOS at the same time since it's still in active development for both (Android is the master). Failing that I could try resizing the sprites to POT and hope that doesn't throw everything off.
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    I always forget Unity never added support for PVRTC2, which removed the POT limitation. Generally Unity’s sprite atlases handle packing sprites into a larger POT texture, but for larger textures like this, yes, it is going to be a problem. Overriding to ETC2 or modifying the texture to be a POT size are both options.

    You can also just select the iOS override tab on your PC version of Unity and set the override values there so it's saved in the "main" project rather than always doing it every time you copy it.
     
    theFongz likes this.
  5. theFongz

    theFongz

    Joined:
    Jul 9, 2014
    Posts:
    10
    Thanks again bgolus. Setting the texture import overrides for all of my build platforms on the one master codebase is exactly what's needed. One pass on the master PC saves countless repasses on the secondary development environment.