0

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

1 Answer 1

2

https://forum.unity.com/threads/cannot-initialize-non-default-texture-with-negative-or-zero-width.1396516/

Issue is fixed by changing this setting to static:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.