Search Unity

How to attach text to a GameObject?

Discussion in 'General Discussion' started by dkalkwarf, Mar 29, 2020.

  1. dkalkwarf

    dkalkwarf

    Joined:
    Mar 29, 2020
    Posts:
    13
    I wish to implement a card game. The game shall be 3D and I wish to eventually animate the cards. The cards are simple - they have a front and back. The front just contains a number. The back shall eventually (later) contain an image or pattern.

    I have created a Prefab of a blank card. It is just a thin, flattened cube. My problem is that I cannot figure out how to add a number (text) to the card. Some research seems to indicate that a TextMesh is the best solution. I have tried to follow the suggestions in those posts, but they do not contain enough detail for me (beginner).

    How do I 'attach' a TextMeshPro to the Prefab? Right-click on the prefab in the Hierarchy and choose TextMeshPro to make the mesh a child of my card? I did that but do not understand how to place it on a face of my card/cube. I also tried creating a TextMeshPro and drag/dropping it on my card, but I have much the same problem (now what?).

    I think I know how to use a script to assign a number to an instance of a card, so I do not believe I need help with that. I just need help in getting some kind of text displayed on my card - don't care if it is static. Once I get that I think I can figure out the rest. BTW, the cards are created in GameManager.Start, but I do not think that is relevant.
     
  2. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,853
    Use the Add Component dropdown at the bottom of the Game Object Inspector window.

    You are probably better making two flat plane meshes back to back as a single card and map images via a material onto both sides. You can also make the mesh have a grid of polys so it can be bendy using deformers.

    First though..Read the manual front to back a few times. Look up what you do not know using a search engine. Do one process at a time and understand what you did or why it won't work before implementing the next process.You will learn.
     
    Ryiah likes this.