Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Bug Create TextMeshPro Font Asset fails - Unity 2023.1.3, TMP 3.0.6

Discussion in 'UGUI & TextMesh Pro' started by lcompton, Jul 7, 2023.

  1. lcompton

    lcompton

    Joined:
    Mar 31, 2018
    Posts:
    108
    Exceptions are being thrown when I create new TMP Font Assets from newly imported TTF and OTF fonts. This was working in 2022.3. Any idea why this is happening?

    Cannot initialize non-default texture with negative or zero width.
    UnityEngine.Texture2D:.ctor (int,int,UnityEngine.TextureFormat,bool)
    TMPro.TMP_FontAsset_CreationMenu:CreateFontAssetFromSelectedObject (UnityEngine.Object) (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Editor/TMP_FontAsset_CreationMenu.cs:220)
    TMPro.TMP_FontAsset_CreationMenu:CreateFontAsset () (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Editor/TMP_FontAsset_CreationMenu.cs:172)

    UnityException: Failed to create texture because of invalid parameters.
    UnityEngine.Texture2D.Internal_Create (UnityEngine.Texture2D mono, System.Int32 w, System.Int32 h, System.Int32 mipCount, UnityEngine.Experimental.Rendering.GraphicsFormat format, UnityEngine.Experimental.Rendering.TextureCreationFlags flags, System.IntPtr nativeTex, System.String mipmapLimitGroupName) (at <a14bafc3d16548339699574d795d5192>:0)
    UnityEngine.Texture2D..ctor (System.Int32 width, System.Int32 height, UnityEngine.TextureFormat textureFormat, System.Int32 mipCount, System.Boolean linear, System.IntPtr nativeTex, System.Boolean createUninitialized, System.Boolean ignoreMipmapLimit, System.String mipmapLimitGroupName) (at <a14bafc3d16548339699574d795d5192>:0)
    UnityEngine.Texture2D..ctor (System.Int32 width, System.Int32 height, UnityEngine.TextureFormat textureFormat, System.Boolean mipChain) (at <a14bafc3d16548339699574d795d5192>:0)
    TMPro.TMP_FontAsset_CreationMenu.CreateFontAssetFromSelectedObject (UnityEngine.Object target) (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Editor/TMP_FontAsset_CreationMenu.cs:220)
    TMPro.TMP_FontAsset_CreationMenu.CreateFontAsset () (at ./Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Editor/TMP_FontAsset_CreationMenu.cs:172)
     
  2. lcompton

    lcompton

    Joined:
    Mar 31, 2018
    Posts:
    108
    I figured it out. I was creating the font asset the wrong way...

    The method that did not work...
    Right click on font file->Create->TextMeshPro->Font Asset

    The method that did work...
    Window->TextMeshPro->Font Asset Creator

    The generated assets work fine when created from the Font Asset Creator window.

    As I mentioned, the first method used to work, so this might be a bug. I'm happy I have a workaround.
     
  3. fengyushi

    fengyushi

    Joined:
    Jan 24, 2016
    Posts:
    2
    I have same problem(or bug).
    and when click on font file ->Create-> Text->Font Asset
    The editor create an asset that contains TMP Material but still a Textcore asset nor a TMP Font Asset file.
    That's really strange.
     
  4. fengyushi

    fengyushi

    Joined:
    Jan 24, 2016
    Posts:
    2
    Upgrade TMP version to 3.2.0-pre.5 can fix it .