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.

TextMesh Pro Cannot initialize non-default texture with negative or zero width

Discussion in 'UGUI & TextMesh Pro' started by Munchy2007, Feb 6, 2023.

  1. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,724
    Getting this error when trying to build standalone with Unity 2023.1.0a24

    Full Error msg
    Code (CSharp):
    1. Cannot initialize non-default texture with negative or zero width.
    2. UnityEngine.Texture2D:Resize (int,int,UnityEngine.TextureFormat,bool)
    3. TMPro.TMP_FontAsset:ClearAtlasTextures (bool) (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_FontAsset.cs:2846)
    4. TMPro.TMP_FontAsset:ClearFontAssetDataInternal () (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_FontAsset.cs:2726)
    5. TMPro.TMP_PreBuildProcessor:OnPreprocessBuild (UnityEditor.Build.Reporting.BuildReport) (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Editor/TMP_PreBuildProcessor.cs:26)
    6. UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()
    Is there anything that can be done about this at the moment?
     
    Last edited: Feb 8, 2023
    Jomity likes this.
  2. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,724
    Hi @Stephan_B ,

    This error seems to be specific to only one of my projects, as I'm able to successfully build another one (for Android), which also uses TMPro with Unity 2023.1.0a24.

    Can you point me in the right direction for what might be the cause and how I might resolve it?

    Thanks :)
     
  3. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    This issue is the result of some API change made by the graphic team where it is no longer possible to resize a texture to size 0. We now have to resize it to size 1.

    I believe that should be fixed in version 3.2.0-pre.4.
     
    Munchy2007 likes this.
  4. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,724
    Thanks for getting back to me, good to hear a fix is in the pipeline.

    I can only see Version 3.0.6 in the package manager (I have Pre-release Packages enabled), how can I find out when 3.2.0-pre.4 is released and how would I get it, will it show in the Package Manager then?

    In the meantime is there any workaround other than reverting to an older Unity version, as any edits I make to the script are automatically reverted.
     
  5. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    You have to enable the option to see Preview Packages in Package Manager Settings. You can access those from the cog wheel in Package Manager itself or via the Project Settings - Advanced Settings.

    You can also add packages by name in the Package Manager as seen below

    upload_2023-2-9_15-59-45.png
     
  6. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,724
    That's great, thanks :)
     
  7. MarvellousLunatic

    MarvellousLunatic

    Joined:
    May 1, 2020
    Posts:
    11
    Greetings,
    I updated Unity to the current alpha and faced the same Issue. I followed @Stephan_B advice and updated TMPro to the üre-release version. However, my font is no build incorrectly or not all.
    upload_2023-2-11_16-47-42.png
    upload_2023-2-11_16-41-55.png
    It's a custom font with dynamic characters.
    What can I do to fix this?
     
    Last edited: Feb 11, 2023
  8. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    6,588
    Make sure that as per the Upgrade Note in the package description that you re-imported the TMP Essential Resources which contain the updated shaders.

    In addition, double check that the default material does have a reference to the font atlas texture.
     
  9. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    323
    I had this OP's issue with 2023.1.0b12 and then the issue mentioned later with the font

    I seen no re-import, so I just removed it and re-added the package and re-imported Essentials

    Working now.

    Thanks
     
    ragetli likes this.