Teoman shipahi
Teoman shipahi

Reputation: 23052

Unity Build Error with TextMeshPro: "Cannot initialize non-default texture with negative or zero width"

I'm encountering a build error in Unity when trying to build my project with TextMeshPro. The error does not occur when I press the play button, only when I try to build and run the project using the shortcut (Ctrl+B). I've already tried removing and re-adding TextMeshPro from the asset store, but the issue persists. Here's the error message:

Cannot initialize non-default texture with negative or zero width.
UnityEngine.Texture2D:Resize (int,int,UnityEngine.TextureFormat,bool)
TMPro.TMP_FontAsset:ClearAtlasTextures (bool) (at ./Library/PackageCache/[email protected]/Scripts/Runtime/TMP_FontAsset.cs:2846)
TMPro.TMP_FontAsset:ClearFontAssetDataInternal () (at ./Library/PackageCache/[email protected]/Scripts/Runtime/TMP_FontAsset.cs:2726)
TMPro.TMP_PreBuildProcessor:OnPreprocessBuild (UnityEditor.Build.Reporting.BuildReport) (at ./Library/PackageCache/[email protected]/Scripts/Editor/TMP_PreBuildProcessor.cs:26)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()

Error building Player: Cannot initialize non-default texture with negative or zero width.

Build completed with a result of 'Failed' in 0 seconds (68 ms)
2 errors
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()

The issue seems to be within the TextMeshPro pre-build process, and I'm not sure how to proceed to fix this. Has anyone else experienced this problem, or does anyone have any suggestions on what steps I can take to resolve this error?

Things I've tried:

Reimporting TextMeshPro assets. Clearing the TMP font asset cache. Checking for updates on the TextMeshPro package. Ensuring all TMP font assets have valid sizes and are not corrupted. I'm using Unity 2023.1.17f1 and TextMeshPro version 3.0.6.

Any help would be greatly appreciated!

enter image description here

Upvotes: 0

Views: 617

Answers (1)

Related Questions