Search Unity

TextMesh Pro How to display TextMesh Pro in a prefab clone behind the sprite and TMP of another clone?

Discussion in 'UGUI & TextMesh Pro' started by mbedair, Sep 17, 2020.

  1. mbedair

    mbedair

    Joined:
    Jan 27, 2020
    Posts:
    2
    Hi, I have some prefab which is a game object contains sprite and some other components and a child of this object is TextMeshPro (not in UI).

    My problem is when instantiating multiple clones of this prefab, the text of the a clone is displayed on top of other sprites, which its parent (the sprite is displayed behind) . IN short, the texts are always on top and the sprites are always on back. I don't want that. I need the sprites and thier texts to be consistent either on top or back of other clones.

    The clones will be spawned randomly in any number and any position. I can think of ugly solution for this by managing the ordering in code with every instantiate, but this is going to decrease the performane a little bit as we expect many objects to be instantiated and destroyed with every frame.

    This is what happends:
    BadOrdering.png

    I want it to be like this:
    CorrectOrdering.png

    Suggestions please.
     
  2. justastupidgamedev

    justastupidgamedev

    Joined:
    Feb 5, 2022
    Posts:
    1
    ik this is a year late but this worked for me add a sprite renderer and change the layer to 2 or anything higher than the clone 2