problem with assets bundles and text mesh pro
Hi, I have a problem with Textmesh pro and the asset bundles. I try to reduce the webgl build size by using assets bundles all seems to work good except that all TextMeshPro texts in the loaded scenes loose their Font Asset linkage so they are all blank. All texts in the instancied prefabs are ok. When I use the rich text tag its ok.
I tried to add all the fonts assets and shaders in an AssetBundle loaded before any other but the problem is the same for all texts in the scene, still ok for prefabs and rich text tag font.
I tried to not load the AssetBundle containing the fonts assets and shaders and now the texts in scene loose their Material linkage so they all have default material, but they have the correct font asset, still ok for prefabs and rich text tag font.
My head start burning and I don't know what to do with these texts. Anybody can help me ?
Answer by sandolkakos · Jun 15, 2018 at 01:48 PM
Try to execute the @Prodigga steps in his post: https://forum.unity.com/goto/post?id=2278648#post-2278648
Answer by Binouze · Jun 06, 2017 at 08:03 AM
The text in prefabs inside an AssetBundle don't work too, same problem as the texts in the loaded scene, font asset link broken.
I tried to remove all TextMeshPro instance that was outside an asset bundle that could cause conflict. Now the only thing I load by default in the build is My Main loading Scene with just an image on it and lot of scripts but nothing related to TextMeshPro.
All other scene are in AssetsBundles, all scene assets are in separate AssetBundles, and I have a common asset bundle with all common textures and the TextMeshPro font assets, materials and shaders.
Help please ;)
Okay after making a WebGL build all is okay and my build is 30$$anonymous$$o lighter than the one without AssetBundle.
But not working in the Editor make the development far harder ! Any way to make it work on editor ?
Answer by brinca · Jun 14, 2018 at 05:13 AM
The problem is that Asset Bundles are compiled for specific platforms, and while static assets such as images tend to be more cross platform, dynamic assets such as shaders have to be compiled for the specific target platform, and will certainly not work on other platforms (which is why you're probably seeing pink squares, indicating that the shader could not be loaded).
The solution is to compile the asset bundle for the platform you're running the editor in (e.g. StandaloneOSXUniversal or StandaloneWindows) and load those bundles while testing in the editor.
An arguably better solution would involve faking the asset bundle behaviour while in the editor, simply by loading the assets directly from the source folders (using AssetDatabase
) instead of the actual bundle. This is a bit more complex but has the added benefit of not having to compile the asset bundles every time you make a change to the original assets.
Lastly, Unity provides an AssetBundle Manager that does all of that, which has since been deprecated, but may be useful for people using older Unity versions.
I'm on Unity 5.6 using asset bundle manager and we are already bundling per platform. That is unfortunately not the issue. T$$anonymous$$P distance field works.... but if it also uses a gradient texture or shadow feature, it does not work properly, and renders as flat white, losing all color, shadows and gradients. Everything looks great in unity. broken on iOS and android (all devices high spec to low spec)