Search Unity

What's the new intended way of setting platform-specific Texture Import settings (overrides)?

Discussion in 'Scripting' started by bsawyer, Oct 18, 2019.

  1. bsawyer

    bsawyer

    Joined:
    May 6, 2014
    Posts:
    37
    UPDATE: I ended up figuring this out... I was making a really dumb mistake. I'm editing this rather than bumping my own thread up with my own comment.

    My primary mistake is that I didn't realize that only some of the overload signatures for the SetPlatformTextureSettings method were marked obsolete: namely, including the one that appears first in Visual Studio's Intellisense. And then when I went to the manual to read the documentation, this was confirmed to me with obsolete signatures being at the top of the page (simply put: I did not realize there were additional, non-obsoleted signatures for this method at first glance)

    Here's the actual answer to my question (this is not clear at all, actually - it's actually kind of weird)
    You have to first GET the platform settings, then set the values to the properties you're tweaking, and then SET the platform settings....
    Code (CSharp):
    1. var androidOverrides = textureImporter.GetPlatformTextureSettings("Android");
    2. androidOverrides.overridden = true;
    3. androidOverrides.format = TextureImporterFormat.ETC2_RGB4;
    4. textureImporter.SetPlatformTextureSettings(androidOverrides);
    Not sure why you have to do it like this, but this seems like something that should be documented more clearly!
    -----------------------

    My original post:


    I'm writing a AssetPostProcessor with the goal of automatically applying Android-specific importer settings on textures places in a certain folder (mainly compression).

    But the obvious methods I can find for doing this are all marked *Obsolete* with no hint as to what the new "correct" method should be!

    What's the scripting API I should be using to:
    • Set "override for <platform>" to true
    • Set "Format" (which is a type "TextureImporterFormat" enum)
    I'd rather not use obsolete APIs if I can help it, if I'm just going to need to go change em later.

     
    Last edited: Oct 18, 2019
  2. catonice

    catonice

    Joined:
    Feb 15, 2020
    Posts:
    6
    Imagine this still being the case in 2020 - thanks dude!
     
  3. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    781
    Now, this is 2024 and it can be works!!!

    Thanks!!!
     
    Last edited: Mar 19, 2024