Search Issue Tracker

By Design

Votes

2

Found in [Package]

1.1.4

Issue ID

1078296

Regression

No

TextMeshPro Material is not loading from the Asset Bundles

Package: Asset Bundles Browser

-

If an Asset Bundle containing TMPro components references a Material that exists as a dependency in some other Asset Bundle, the component fails to reference it even though both Bundles are loaded, falling back to the Default Material

To reproduce:

1. Download attached project "text mesh bundle test.zip" and open in Unity
2. Open "SampleScene" scene
3. Select "Main" gameObject in Hierarchy
4. Uncheck "Is Workaround Active" box
5. Enter Play mode
6. Observe that the Default Material is loaded instead of the Custom Material

Notes:
- This issue appears both on Windows and OSX
- Workaround: Assing the Material manually. To see it working, select the "Main" object in the Hierarchy then check the "Is Workaround Active" box, and enter Play mode again. You will see the expected behavior
- This is not Duplicate of this case: https://issuetracker.unity3d.com/issues/shaders-and-materials-are-not-loaded-correctly-when-they-are-in-separate-asset-bundles

Reproduced on Package version 1.1.4 and 1.7.0

Reproduced on Unity 2018.2.7f1 and 2018.3.0b1
Could not reproduce on Unity 2018.1.9f2 because TMPro becomes corrupted

  1. Resolution Note:

    I had a chance to take a second look at this case and was able to identify the cause of the behavior which as it turns out is not a bug.

    Why is TextMesh Pro reverting / using the default material of the font asset instead of using the custom material when the bundle is loaded?

    In the provided project, there are two bundles. The "font materials" which includes the BRUSHSCI SDF custom material and the auto included BRUSHSCI SDF font asset. The 2nd bundle includes a prefab text object which references the BRUSHSCI font asset. In theory, everything should work as expected however, due to an oversight when the bundles were created (a difficult / easily overlooked detail) the bundles end up with two different instances of the atlas texture used by the font asset and the custom material.

    Since TMP tries to ensure that the atlas texture of any assigned material matches the atlas texture of the assigned font asset (which in this case do not match), TMP reverts to using the default material of the font asset to make sure the text renders correctly.

    So what detail was overlooked when creating the bundles?

    The BRUSHSCI SDF font asset was never assigned to font materials bundle. As a result, we end up with the BRUSHSCI SDF font asset (the atlas texture) being auto included but since it is pulled in automatically, it is distinct from the atlas texture used by the font asset BRUSHSCI SDF also auto included in the ui elements bundle.

    The solution is to assign the BRUSHSCI SDF font asset to the font materials bundle and rebuilding the bundles. When doing so, we end up with a shared texture between the two bundles which in turn results in the custom material correctly being assigned to the text object since in this case the atlas texture is the same as the one referenced by the font asset.

    My apologies for not catching the first time I looked at the project.

    Regards,

    Stephan

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.