Search Unity

Question TextMeshProUGUI dont show on android build

Discussion in 'UGUI & TextMesh Pro' started by jisase, May 2, 2023.

  1. jisase

    jisase

    Joined:
    Oct 22, 2020
    Posts:
    17
    Hello everyone!

    I am developing a 3D third person shooter and I have implemented an object pool to optimize the instancing of repeating objects such as bullets... among the objects that my object pool instantiates there is an object with a TextMeshPro component which is used to display the damage done by each bullet.

    However, when my object pool instantiates at the start of the game all the objects in its list and disables them when this object with TextMeshPro component is present and I build for Android, when I run the game on my phone I see that it also disables any other object with TextMeshProUGUI components (all belonging to my UI) without even being added to the list of the object pool and without being components of the same type ... In the editor it doesn't happen, it only happens in the build.

    Am I doing something wrong? if you can help me I would be very grateful.

    I leave the code of my object pool:
    Code (CSharp):
    1. public class ObjectPooler : MonoBehaviour
    2. {
    3.     public List<Pool> pools;
    4.     public Dictionary <string, Queue<GameObject>> poolDictionary;
    5.  
    6.     void Start()
    7.     {
    8.         poolDictionary = new Dictionary <string, Queue<GameObject>>();
    9.  
    10.         foreach (Pool pool in pools)
    11.         {
    12.             Queue<GameObject> objectPool = new Queue<GameObject>();
    13.  
    14.             for (int i = 0; i < pool.size; i++)
    15.             {
    16.                 GameObject obj;
    17.  
    18.                 if (pool.haveParent)
    19.                 {
    20.                     obj = Instantiate(pool.prefab, pool.parent);
    21.                 }
    22.                 else
    23.                 {
    24.                     obj = Instantiate(pool.prefab);
    25.                 }
    26.  
    27.                 obj.SetActive(false);
    28.                 objectPool.Enqueue(obj);
    29.             }
    30.  
    31.             poolDictionary.Add(pool.tag, objectPool);
    32.         }
    33.     }
    34.  
    35.     public GameObject SpawnFromPool(string tag, Vector3 position, Quaternion rotation)
    36.     {
    37.         if(!poolDictionary.ContainsKey(tag))
    38.         {
    39.             Debug.Log("Pool with tag " + tag + " doesn't excist.");
    40.             return null;
    41.         }
    42.  
    43.         GameObject objectToSpawn = poolDictionary[tag].Dequeue();
    44.  
    45.         objectToSpawn.SetActive(true);
    46.         objectToSpawn.transform.SetPositionAndRotation(position, rotation);
    47.  
    48.         poolDictionary[tag].Enqueue(objectToSpawn);
    49.  
    50.         return objectToSpawn;
    51.     }
    52.  
    53. [System.Serializable]
    54. public class Pool
    55. {
    56.     public string tag;
    57.     public GameObject prefab;
    58.     public int size;
    59.     [Space(10)]
    60.  
    61.     public bool haveParent;
    62.     [ConditionalField(nameof(haveParent), false, true)] public Transform parent;
    63. }