Search Unity

TextMesh Pro TextMeshPro unable to reference/display a font asset loaded in asset bundle

Discussion in 'UGUI & TextMesh Pro' started by yanivng, May 2, 2018.

  1. yanivng

    yanivng

    Joined:
    May 21, 2017
    Posts:
    43
    Hi,

    I have a prefab built of game objects that have the Text Mesh Pro UGUI script on it. The script is referencing a font asset.
    This prefab is a part of an asset bundle called "menus".
    This font asset is part of a directory which belong to an asset bundle called "fonts":

    During editor time, the font asset is displayed correctly along with its material presets:
    But during run time, after asset bundles are downloaded, the preset selected is incorrect (the default preset?/default font asset?).

    I have already tried taking the font asset out of the "fonts" directory (which belongs to an asset bundle) - didn't help.

    Any help/suggestions are highly appreciated!

    (Using Unity 2017.4.1f1)
     
    roi_laredo likes this.
  2. jasonnk

    jasonnk

    Joined:
    Sep 30, 2016
    Posts:
    7
    Did you find a solution to this problem? I'm having the same issue
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
  4. jasonnk

    jasonnk

    Joined:
    Sep 30, 2016
    Posts:
    7
    Thanks, looks like my issue was that the shaders were both in a resources folder and an asset bundle, my fix was to just remove the shaders from the bundle and leave them in the resources folder and it 'seemed' to work (for now)
     
    Stephan_B likes this.
  5. Ryukidmm

    Ryukidmm

    Joined:
    Aug 14, 2018
    Posts:
    6

    Attached Files:

    • sc_.png
      sc_.png
      File size:
      5.8 KB
      Views:
      1,077
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    That is the shader reference that is missing. When you load the bundle, you will have to manually re-assign the correct shader to the material used by those font assets. If you are using the same shader on all text objects, that is trivial to do as you load the bundle.

    I realize this is an extra step. Hopefully at some point this will no longer be necessary.
     
    Ryukidmm likes this.
  7. vladk

    vladk

    Joined:
    Jul 10, 2008
    Posts:
    167
    Hello, I'm struggling with the same (visually) issue. But it shows itself ONLY on MacOS builds. Windows and Android works fine. Also it is only the TextMeshPro compoenent, that has a problem, all other objects inside the bundle are rendered fine. The TextMeshPro component in the bundle uses the same shader I use for some other TextMeshPro objects in scene (that are not in the bundle) and they are rendered fine.
    I use this script to reapply the shader after I instantiated the prefab from the bundle into the scene (do it for all the prefabs from the bundle):


    Code (CSharp):
    1. private void ReapplyShaders(GameObject go)
    2.     {
    3.         foreach (Renderer rend in go.GetComponentsInChildren<Renderer>(true))
    4.         {
    5.             Material[] materials = rend.sharedMaterials;
    6.          
    7.             for (int i = 0; i < materials.Length; i++)
    8.             {
    9.                 if (materials[i] == null || materials[i].shader == null)
    10.                     continue;
    11.  
    12.                 string shaderName = materials[i].shader.name;
    13.                 Shader shader = Shader.Find(shaderName);
    14.  
    15.                 if (shader != null)
    16.                     materials[i].shader = shader;
    17.                 else
    18.                     Debug.LogWarning("Shader " + shaderName + " not found!");
    19.             }
    20.  
    21.             rend.materials = materials;
    22.         }
    23.     }
    and here is the Player.log from the MacOS build

    Initialize engine version: 2018.3.8f1 (fc0fe30d6d91)
    GfxDevice: creating device client; threaded=1
    Renderer: AMD Radeon HD 6630M OpenGL Engine
    Vendor: ATI Technologies Inc.
    Version: 4.1 ATI-1.68.21
    GLES: 0
    GL_ARB_blend_func_extended GL_ARB_draw_buffers_blend GL_ARB_draw_indirect GL_ARB_ES2_compatibility GL_ARB_explicit_attrib_location GL_ARB_gpu_shader5 GL_ARB_instanced_arrays GL_ARB_internalformat_query GL_ARB_occlusion_query2 GL_ARB_sample_shading GL_ARB_sampler_objects GL_ARB_separate_shader_objects GL_ARB_shader_bit_encoding GL_ARB_shader_subroutine GL_ARB_shading_language_include GL_ARB_tessellation_shader GL_ARB_texture_buffer_object_rgb32 GL_ARB_texture_cube_map_array GL_ARB_texture_gather GL_ARB_texture_query_lod GL_ARB_texture_rgb10_a2ui GL_ARB_texture_storage GL_ARB_texture_swizzle GL_ARB_timer_query GL_ARB_transform_feedback2 GL_ARB_transform_feedback3 GL_ARB_vertex_type_2_10_10_10_rev GL_ARB_viewport_array GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_texture_compression_s3tc GL_EXT_texture_filter_anisotropic GL_EXT_texture_mirror_clamp GL_EXT_texture_sRGB_decode GL_APPLE_client_storage GL_APPLE_container_object_shareable GL_APPLE_flush_render GL_APPLE_object_purgeable GL_APPLE_rgb_422 GL_APPLE_ro
    w_bytes GL_APPLE_texture_range GL_ATI_texture_mirror_once GL_NV_texture_barrier
    OPENGL LOG: Creating OpenGL 4.1 graphics device ; Context level <OpenGL 4.1> ; Context handle 604894208
    Begin MonoManager ReloadAssembly
    - Completed reload, in 0.195 seconds
    WARNING: RGB Compressed BC6H UFloat format is not supported, decompressing texture
    UnloadTime: 3.178339 ms
    URI=file:/Users/soroban/Library/Application Support/com.Soroban.Soroboom/SoroboomDB.db
    (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

    CreateSchema=0
    (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

    TruncateStatistics=0
    (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

    Unloading 6 Unused Serialized files (Serialized files now loaded: 0)
    WARNING: RGB Compressed BC6H UFloat format is not supported, decompressing texture
    Setting up 2 worker threads for Enlighten.
    Thread -> id: 70000f6f8000 -> priority: 1
    Thread -> id: 70000f77b000 -> priority: 1
    IndexOutOfRangeException: Index was outside the bounds of the array.
    at SorobanUtility+<GetIP>d__4.MoveNext () [0x0006e] in <10e1949ee9fb492d81a4b32ab0c8f694>:0
    at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00027] in <4afd52b44458411089197a6925c2e646>:0
    (Filename: <10e1949ee9fb492d81a4b32ab0c8f694> Line: 0)

    UnloadTime: 0.694324 ms

    Unloading 6 unused Assets to reduce memory usage. Loaded Objects now: 3140.
    Total: 20.266830 ms (FindLiveObjects: 0.667245 ms CreateObjectMapping: 0.084124 ms MarkObjects: 19.465256 ms DeleteObjects: 0.049607 ms)

    Unloading 3 Unused Serialized files (Serialized files now loaded: 0)
    WARNING: RGB Compressed BC6H UFloat format is not supported, decompressing texture
    UnloadTime: 0.252311 ms

    Unloading 3 unused Assets to reduce memory usage. Loaded Objects now: 3144.
    Total: 23.664842 ms (FindLiveObjects: 0.486174 ms CreateObjectMapping: 0.062288 ms MarkObjects: 23.025663 ms DeleteObjects: 0.090177 ms)

    {"url":"https://adm-test.soroban.ua/soroboom/adm_test/Standalone/dedsorobanprefab","version":10003}
    (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

    {"url":"https://adm-test.soroban.ua/soroboom/adm_test/Standalone/staticbundle","version":10003}
    (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

    Unloading 4 Unused Serialized files (Serialized files now loaded: 2)
    WARNING: RGB Compressed BC6H UFloat format is not supported, decompressing texture
    WARNING: Shader Unsupported: 'Mobile/Diffuse' - Pass 'Meta' has no vertex shader
    WARNING: Shader Unsupported: 'Mobile/Bumped Diffuse' - Pass 'Meta' has no vertex shader
    WARNING: Shader Unsupported: 'Standard' - Pass 'META' has no vertex shader
    WARNING: Shader Unsupported: 'Standard' - Pass 'META' has no vertex shader
    UnloadTime: 0.283060 ms
    The character used for Underline and Strikethrough is not available in font asset [HIROSHT].
    (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

    The character used for Ellipsis is not available in font asset [LobsterCustom-Regular].
    (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

    The character used for Ellipsis is not available in font asset [LobsterCustom-Regular].
    (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

    The character used for Ellipsis is not available in font asset [LobsterCustom-Regular].
    (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

    The character used for Ellipsis is not available in font asset [LobsterCustom-Regular].
    (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

    Desired shader compiler platform 15 is not available in shader blob
    (Filename: Line: 562)

    Desired shader compiler platform 15 is not available in shader blob
    (Filename: Line: 562)

    WARNING: Shader Unsupported: 'Legacy Shaders/VertexLit' - Pass '' has no vertex shader
    ERROR: Shader Shader is not supported on this GPU (none of subshaders/fallbacks are suitable)WARNING: Shader Unsupported: 'Legacy Shaders/VertexLit' - Setting to default shader.
    WARNING: Shader Unsupported: 'Standard' - Pass 'FORWARD' has no vertex shader
    WARNING: Shader Unsupported: 'Standard' - Pass 'FORWARD_DELTA' has no vertex shader
    WARNING: Shader Unsupported: 'Standard' - Pass 'ShadowCaster' has no vertex shader
    WARNING: Shader Unsupported: 'Standard' - Pass 'META' has no vertex shader
    WARNING: Shader Unsupported: 'Standard' - All passes removed
    WARNING: Shader Unsupported: 'Standard' - Pass 'FORWARD' has no vertex shader
    WARNING: Shader Unsupported: 'Standard' - Pass 'FORWARD_DELTA' has no vertex shader
    WARNING: Shader Unsupported: 'Standard' - Pass 'ShadowCaster' has no vertex shader
    WARNING: Shader Unsupported: 'Standard' - Pass 'DEFERRED' has no vertex shader
    WARNING: Shader Unsupported: 'Standard' - Pass 'META' has no vertex shader
    WARNING: Shader Unsupported: 'Standard' - All passes removed
    Desired shader compiler platform 15 is not available in shader blob
    (Filename: Line: 562)

    WARNING: Shader Unsupported: 'TextMeshPro/Mobile/Distance Field' - Pass '' has no vertex shader
    ERROR: Shader Shader is not supported on this GPU (none of subshaders/fallbacks are suitable)WARNING: Shader Unsupported: 'TextMeshPro/Mobile/Distance Field' - Setting to default shader.
    Upgrading font asset [Lobster] to version 1.1.0.
    (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

    WARNING: Shader Unsupported: 'Legacy Shaders/Transparent/Cutout/Diffuse' - Pass 'Meta' has no vertex shader
    WARNING: Shader Unsupported: 'Legacy Shaders/Transparent/Cutout/Bumped Diffuse' - Pass 'Meta' has no vertex shader

    Unloading 1000 unused Assets to reduce memory usage. Loaded Objects now: 6448.
    Total: 32.282930 ms (FindLiveObjects: 1.069492 ms CreateObjectMapping: 0.143728 ms MarkObjects: 30.624896 ms DeleteObjects: 0.440710 ms)

    Unloading 3 Unused Serialized files (Serialized files now loaded: 2)
    WARNING: RGB Compressed BC6H UFloat format is not supported, decompressing texture
    UnloadTime: 12.340093 ms

    Unloading 182 unused Assets to reduce memory usage. Loaded Objects now: 3190.
    Total: 32.639204 ms (FindLiveObjects: 0.526025 ms CreateObjectMapping: 0.083641 ms MarkObjects: 31.576124 ms DeleteObjects: 0.452957 ms)

    Help me, Obi-Wan Kenobi. You're my only hope.
     
  8. Dazo1985

    Dazo1985

    Joined:
    Mar 13, 2019
    Posts:
    26
    Issue:
    Had this too.
    When TMProUGUI was loaded via asset bundle.

    The text was not visible, It lost its TextAsset.


    Solution:
    Instantiate it and set the TextAsset for each child with the TMProUGUI component.
    (based on the approach by
    @vladk )



    GameObject myGameObject = GameObject.Instantiate(current.gameObject, targetParent);
    ReapplyTextAsset(myGameObject);



    Code (CSharp):
    1.   private void ReapplyTextAsset(GameObject go)
    2.     {
    3.         foreach (TextMeshProUGUI txtMeshPro in go.GetComponentsInChildren<TextMeshProUGUI>())
    4.         {
    5.  
    6.             txtMeshPro.font = _FontAsset;
    7.  
    8.         }
    9.  
    10.     }
     
    Last edited: Jan 30, 2020
    ArkhoMusic likes this.
  9. javierfed

    javierfed

    Joined:
    Apr 10, 2015
    Posts:
    50
    I am having this issue, but only on assets brought in by one package. I have other packages that come in and render their text mesh pro assets just fine... any ideas? or am I just to replace all TMP materials as they appear, regardless.