Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity 5.5 EncodetoPNG with texture format deprecated.

Discussion in 'Scripting' started by KKS21199, Mar 3, 2017.

  1. KKS21199

    KKS21199

    Joined:
    Nov 22, 2012
    Posts:
    139
    Hi,

    Unsupported texture format - needs to be ARGB32, RGBA32, RGB24, Alpha8 or one of float formats

    This is the error I get when I try to encode something to png or jpg using EncodeToPNG or EncodeToJPG Functions. I was working with one of my old libraries from Unity 5.0. I see that textureImporter.textureFormat is deprecated so how could I encode a asset png/jpg without setting the format.
     
  2. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    You now have to create an instance of TextureImporterPlatformSettings and set the format on it (along with other fields, including the platform) then call textureImporter.SetPlatformTextureSettings passing in the settings.
     
    KKS21199 likes this.
  3. KKS21199

    KKS21199

    Joined:
    Nov 22, 2012
    Posts:
    139
    Thanks :) That works. So now users can't customize the format directly on the importer ?
     
  4. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    You still have full control in the inspector.
     
  5. KKS21199

    KKS21199

    Joined:
    Nov 22, 2012
    Posts:
    139
    I mean this


    as you can see I can't set the format myself within the editor.
     
  6. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    You can do it for your build targets though which is what is important.