Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Text on a game map

Discussion in 'Getting Started' started by IK, Mar 2, 2016.

  1. IK

    IK

    Joined:
    Oct 29, 2012
    Posts:
    34
    In my current project I have a hex map (2d) that needs to display text names of hexes that have cities. I haven't found a simple way to deal with the text as I can the sprite icon for the city. Searching online I see that some use a worldview canvas for text, but how would this work? From what I read it would seem that each hex would need its own canvas (and would be every complex to make from a script). Would that slow down my game or clash with my existing overlay canvas I use for the menus? Is there an easier way to go about this?
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    The worldview canvas is certainly the easiest way to go. Yes, each hex (that needs text) would have its own canvas, but no, that's not all that hard to make from a script — though you probably shouldn't do it that way anyway; instead just instantiate a prefab that already has the canvas and the UI.Text in it.

    No, it won't slow down your game, nor will it clash with your existing menu canvas. A Canvas is just a handful of properties that Unity uses to take your UI objects (e.g. text) and figure out where and how to put the OpenGL triangles it needs to draw them where you want them. There is no harm in using as many as you need.

    The only reasonable alternative would be to use something like the TextMesh asset, which is fine if that's the way you want to go. But the Canvas is built in and works fine.
     
    Ryiah and Schneider21 like this.
  3. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    If you are going to use a ton of world space canvases for labels only, consider removing the graphics raycaster component on anything that doesn't need to be clickable.
     
    Ryiah likes this.
  4. IK

    IK

    Joined:
    Oct 29, 2012
    Posts:
    34
    Thanks guys!