Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Documentation for tilemaps

Discussion in '2017.2 Beta' started by darthdeus, Jul 11, 2017.

  1. darthdeus

    darthdeus

    Joined:
    Oct 13, 2013
    Posts:
    76
    Is there any documentation for the new 2d tilemap feature that should be in this beta?
     
  2. plauk

    plauk

    Joined:
    Jun 4, 2013
    Posts:
    10
    Would love to know this also.
     
  3. primitiveconcept

    primitiveconcept

    Joined:
    Feb 23, 2013
    Posts:
    8
    plauk and Peter77 like this.
  4. icepower2012

    icepower2012

    Joined:
    Jan 14, 2015
    Posts:
    7
    We need the documentation for tilemap!
     
  5. Lightrail

    Lightrail

    Joined:
    Apr 12, 2013
    Posts:
    37
    I too would like to know if there's any current tile map documentation. I keep trying to edit my tile palette but it keeps resetting despite saving the scene/project.
     
  6. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    primitiveconcept and plauk like this.
  7. plauk

    plauk

    Joined:
    Jun 4, 2013
    Posts:
    10
    Awesome. Thanks for the update!
     
  8. primitiveconcept

    primitiveconcept

    Joined:
    Feb 23, 2013
    Posts:
    8
  9. diegzumillo

    diegzumillo

    Joined:
    Jul 26, 2010
    Posts:
    418
    Godammit. Just made a new topic asking for this and here it is.
     
  10. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    And also make the tool a bit more like rotorz tile mapper, so that creation of brushes does not need a programmer.
    please focus on some Artist friendly brush creation wizard.
     
  11. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967


    Do you mean something like this?

    This is available for download at https://github.com/Unity-Technologies/2d-extras
     
  12. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    Yes like that thanks! :)

    And if you can also add a layer menu, like photoshop, where its easy to toggle layer visibility that would be great!

     
  13. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    Or Make this menu have a way to become possible as standalone window.
    Its annoying that it always closes and can't be open all the time to quickly access.



     
    orb likes this.
  14. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    That thing is my greatest annoyance in Unity. I want more dockable tabs with the things which are likely to change a lot, especially early in a project. Some things are just too deeply nested inside menus and clicks, despite being fundamental settings you need access to often.
     
  15. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521


    Just have a look at how Maya does layers. It would make our workflow in unity so much easier.
     
    orb likes this.
  16. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    Yes, or really ANY art software (including external sprite tools).
     
  17. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    I was trying to make the window for the layers myself but the unity API does not seem to allow to enable or disable the layers, only to read and set the names.

    so I gave up and I'm hoping someone from unity will make the window.

    This may seem off topic but its related to working efficient in unity Tile maps



    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEditor;
    6.  
    7. public class Layers : EditorWindow
    8. {
    9.     string SLayers = "Layers";
    10.     bool groupEnabled;
    11.     bool myBool0 = true;
    12.     bool myBool1 = true;
    13.     bool myBool2 = true;
    14.     bool myBool3 = true;
    15.     bool myBool4 = true;
    16.     bool myBool5 = true;
    17.    
    18.     float myFloat = 1.23f;
    19.    
    20.     string Layer0 = "name0";
    21.     string Layer1 = "name1";
    22.     string Layer2 = "name2";
    23.     string Layer3 = "name3";
    24.     string Layer4 = "name4";
    25.     string Layer5 = "name5";
    26.    
    27.     // Add menu item named "My Window" to the Window menu
    28.     [MenuItem("Window/Layers")]
    29.    
    30.     public static void ShowWindow()
    31.     {
    32.         //Show existing window instance. If one doesn't exist, make one.
    33.         EditorWindow.GetWindow(typeof(Layers));
    34.     }
    35.    
    36.     void OnGUI()
    37.     {
    38.        
    39.         Layer0 = (LayerMask.LayerToName(0));
    40.         Layer1 = (LayerMask.LayerToName(1));
    41.         Layer2 = (LayerMask.LayerToName(2));
    42.         Layer4 = (LayerMask.LayerToName(4));
    43.         Layer5 = (LayerMask.LayerToName(5));
    44.         GUILayout.Label (("Layers"),EditorStyles.whiteLargeLabel);
    45.        
    46.        
    47.         groupEnabled = EditorGUILayout.BeginToggleGroup ("Optional Settings", groupEnabled);
    48.         myBool0 = EditorGUILayout.Toggle (Layer0, myBool0);
    49.         myBool1 = EditorGUILayout.Toggle (Layer1, myBool1);
    50.         myBool2 = EditorGUILayout.Toggle (Layer2, myBool2);
    51.         myBool4 = EditorGUILayout.Toggle (Layer4, myBool4);
    52.         myBool5 = EditorGUILayout.Toggle (Layer5, myBool5);
    53.    
    54.         EditorGUILayout.EndToggleGroup ();
    55.     }
    56. }
    57.  
    58.  
     
  18. Supergeek

    Supergeek

    Joined:
    Aug 13, 2010
    Posts:
    103
    It would be nice to have an example that creates Tilemaps programmatically. I'm sure there is a sizeable audience that wants to generate maps through code instead of manually.
     
    arkogelul likes this.
  19. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    At least two of us!
     
  20. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    Do you mean scenario where you have art+tilesets built-in or do you mean generate everything on-the-fly?
     
  21. summerian

    summerian

    Joined:
    Jul 6, 2014
    Posts:
    140
    Pretty sure they mean everything. As in a procedurally generated dungeon. I would also be keen on using it that way.
     
  22. Supergeek

    Supergeek

    Joined:
    Aug 13, 2010
    Posts:
    103
    Let's say I have a whole boatload of pre-existing spritesheets in RPG Maker format, for example. I'd like to be able to handle loading and parsing the graphics through code, and displaying the tilemaps through code, with the only thing in the Scene being a game controller Gameobject with all scripts attached, and UI canvas elements.
     
  23. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419

    This looks pretty awesome, but I wonder if it would be possible to use rules for different types of slopes @keely ?

    I was thinking it would be nice to have variations of a corner tile, such as a slope of varying degrees in a 2D platformer. Is this possible?
     
  24. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    You can make 45 deg slope tile with this tool. For more exotic ones you need to make your own custom tile or extend this system.
     
  25. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    What and where would I look at specifically to do just that?

    Also, if you don't mind me asking, how is paging done in this system -- or is there any tile-paging system implemented at all? I was mainly wondering if the paging system could also be extended and/or piggybacked off of for other gameobject-paging purposes?
     
  26. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    If you want to make your own custom tile, it all comes down to inheriting TileBase class and overriding GetTileData method. Check our github for many examples.

    See:
    https://github.com/Unity-Technologies/2d-techdemos
    https://docs.unity3d.com/2017.2/Documentation/ScriptReference/Tilemaps.TileBase.html
    https://docs.unity3d.com/2017.2/Documentation/ScriptReference/Tilemaps.TileBase.GetTileData.html

    I can't be sure what you mean by paging, but if you mean splitting big tilemap into smaller chunks, then nothing like that is exposed to end-user at the moment.
     
  27. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Thanks @keely -- that's just what I needed!

    Also:

    That's exactly what I mean -- I can see being able to hook into this "big-tilemap-to-smaller-chunks" system being very useful to many different people for lots of reasons, including large world streaming, gameobject streaming, etc. Would it be possible to expose something like this to users so we can simply extend it to our purposes?

    Having a C++ backend would be great for any grid-based spatial sorting -- especially if we could set a few of our own parameters and let the tile paging/streaming system do its thing to work out when something goes in/out of the viewport/etc. After all, being able to do this with grid-based spatial data is useful for all sorts of purposes. I'd be satisfied if it were possible to at least piggyback off the current tile chunk's spatial system, especially if it would allow the possibility of a Z axis lookup. Maybe we could get an event to allow setting a gameobject on/off in the C++ side due to its visibility in the viewport or something, just to speed this sort of "grid-based lookup/paging/streaming" thing up?

    Is this sort of thing something that might be in the cards?

    Pretty please?
     
    Last edited: Sep 18, 2017
  28. Puggy

    Puggy

    Joined:
    Jun 10, 2015
    Posts:
    6
    This is something I've been thinking about recently as well (paging / breaking a large map into smaller chunks). It's something that can already be scripted with what they've currently exposed in the Tilemap API. The tiles are stored in the tilemap as an array of Tile objects which you can retrieve, manipulate, then send back to the tilemap to update it. You can update the map only within a specific region, so you can push chunks of the larger map and clear others, as the player moves around, or whatever, as needed.

    I looked into it because I'm considering building an asset for the Asset Store that does procedural generation of worlds using the Tilemap, and the plan was to handle paging as part of the package. I posted a few days ago in the public WIP forum, asking for feedback on the idea, if anyone is interested in it. It can be found here.
     
    awesomedata likes this.
  29. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Wow. The API seems very robust!

    Is there any way to make the Grid support 3D tiles (i.e. 2D tiles with depth), @keely ? Seems like the lookup is already there for that.
     
  30. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967
    Like Puggy said, paging can be done manually and that is how we predicted users would solve it.

    That said, we are discussing exposing the internal paging more as it might be low hanging fruit. No promises, though.

    Technically Grid & Tilemap support 3D all the way so in theory you can make 3D stuff, but in reality we are lacking the UI and some API to advertise it as real 3D support. Stay tuned!
     
    Puggy and awesomedata like this.
  31. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Sweet!!! I love that you guys are considering doing this!

    So what part of the API would it require right now to programmatically place a few "Tiles" (in 3D space) on a "Tilemap" and then look them up in 3D on a "Grid" using native API functions (sorry if there's an example of this somewhere, documentation is confusing -- for example, what exactly is a "Proxy-Grid" for anyway lol?)
     
    Last edited: Sep 19, 2017
  32. keely

    keely

    Joined:
    Sep 9, 2010
    Posts:
    967


    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Tilemaps;
    3.  
    4. public class Tile3DTest : MonoBehaviour
    5. {
    6.     public Tile m_Tile;
    7.  
    8.     void Start ()
    9.     {
    10.         m_Tile.flags = TileFlags.None;
    11.         GameObject go = new GameObject("Grid");
    12.         Grid grid = go.AddComponent<Grid>();
    13.         grid.cellSize = Vector3.one; // Default is (1,1,0)
    14.         Tilemap tilemap = go.AddComponent<Tilemap>();
    15.         go.AddComponent<TilemapRenderer>();
    16.  
    17.         for(int z = 0; z < 10; z++)
    18.         {
    19.             for(int y = 0; y < 10; y++)
    20.             {
    21.                 for (int x = 0; x < 10; x++)
    22.                 {
    23.                     Vector3Int p = new Vector3Int(x, y, z);
    24.                     tilemap.SetTile(p, m_Tile);
    25.                     tilemap.SetColor(p, new Color(x / 10f, y / 10f, z / 10f));
    26.                 }
    27.             }
    28.         }
    29.     }
    30. }
     
    Last edited: Sep 19, 2017
  33. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Just what I needed! Thanks again, @keely -- You rock!!! :)