Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Setting up tiles for roguelike?

Discussion in 'UGUI & TextMesh Pro' started by gallenwolf, Jan 28, 2015.

  1. gallenwolf

    gallenwolf

    Joined:
    Mar 11, 2012
    Posts:
    118
    Hello!
    Been playing with the new UI and I really like how it works together, and the documentation is pretty solid. Draw calls are rather high, especially since I do not have pro but I'll worry about that later.

    Anyways, main question: For a roguelike, how would one approach creating the tiles in the new UI? My current plan is to use one gameobject+image script per tile, and procedurally instantiate these. Is this the right approach or is there a better way?

    Thanks!
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    That's not a good idea; you would have way too many objects, unless the level is very small. Also the UI isn't appropriate for creating actual game graphics; for that you would use sprites. The usual technique is to create combined mesh chunks using the Mesh class, though with SpriteTile I took an alternate approach of creating a pool of sprites that are recycled as the camera moves, which works very well.

    --Eric
     
    gallenwolf likes this.
  3. gallenwolf

    gallenwolf

    Joined:
    Mar 11, 2012
    Posts:
    118
    Eric, thanks! Am I right to say that you are suggesting one of two approaches:
    a) Each tile is a mesh, and use the Mesh.combineMeshes() to merge them into one mesh, so, theoretically one draw call with a texture atlas?
    b) Simply use individual sprites for each tile?

    Cheers!

    PS: SpriteTile looks wicked!
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    No, you'd use the Mesh class to create a mesh where each tile is a quad (two triangles). The idea is to not have each tile be an individual mesh or object, since that's inefficient or impossible, depending on how many tiles you have. So there's no need for Mesh.CombineMeshes.

    Again no, unless the level is very small.

    Thanks! It only uses enough sprites to fill the screen, so whether you have 1 million tiles or 100 tiles, typically the same number of sprites are used.

    --Eric
     
  5. gallenwolf

    gallenwolf

    Joined:
    Mar 11, 2012
    Posts:
    118
    Ah thanks for the clarification Eric! Cheers!