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

[RELEASED] Super Tilemap Editor

Discussion in 'Assets and Asset Store' started by CreativeSpore, Feb 21, 2016.

  1. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    I don't have an ETA yet, it is something that will come soon or later. If I try to guess I think it will come during the first quarter of the next year.
     
  2. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    You need to use Point filter mode in the normal map texture to get rid of seams.
    Also, use the Cutout Rendering mode to skip the alpha pixels from rendering.
    upload_2017-11-18_11-29-52.png

    Here you can see an example of Normal map applied to a tilemap.
    upload_2017-11-18_11-38-28.png
     
  3. RecursiveFrog

    RecursiveFrog

    Joined:
    Mar 7, 2011
    Posts:
    350
    Cutout was the answer to the original normal map question. Hooray! Thank you!

    EDIT : It was actually a problem with the textures not being flush, not the normal maps. I found your advice elswhere in the thread to set an Inner Padding, and this did help. I'm not sure I understand what inner padding is supposed to be, though. What's being adjusted?
     
    Last edited: Nov 19, 2017
  4. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    The Inner padding is an easy way to get rid of seams. You know the problems of seams in due precision error. Sometimes a neighbor pixel outside the UV rect is rendered creating the seams. So Inner Padding just stretches the UV rect a number of pixels to the inside. For example, an Inner Padding of 1 will cut a pixel,and a value of 0.2 will cut 20% of the external pixel and just scale the tile to fill the missing part.
    Usually a value of 0.2 will fix the seams without a big impact in the tile look.
    Another way to remove seams is by extruding the tile color. You can do that using the Atlas Editor Window:
     
  5. RecursiveFrog

    RecursiveFrog

    Joined:
    Mar 7, 2011
    Posts:
    350
    That's very informative. Thank you for the answers. :)

    I'm currently looking at the API for updating tiles, because I'm trying to update a tile at runtime. However, it seems like I'm getting empty tile data (uint.MaxValue) for every tile I try to access. Here's a very simple example:

    I try to get data at runtime for the tile at (x1, y0)
    tile10.png

    But the results from the tile API says that the data is null
    tile10log.png

    Code
    tile10code.png

    Am I misunderstanding what this API is for? My understanding is that I should be able to obtain a uint value representing a tile in the map at a given xy, and then use tilemap.SetTileData() to update the tile at runtime, but it looks like there isn't any tile data even when I poll the tilemap?
     
  6. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    For what I see in your code, you are trying to access a local position not a grid position.
    If you use a Vector2 with a value of (1, 0) you are really trying to get the grid cell where the local position (1, 0) in included.
    There is another version of methods GetTile and GetTileData where you pass two integers with the grid coordinates:
    Tile tile = tilemap.GetTile(1, 0); // this will return you the tile at grid position (1, 0)

    You can find more information about this in this tutorial:
    https://creativespore.com/2017/10/23/editing-tiles-of-an-stetilemap-from-script/
     
  7. RecursiveFrog

    RecursiveFrog

    Joined:
    Mar 7, 2011
    Posts:
    350
    Thanks for the link to the tutorial. That answered my question, and helped me to update the tile at runtime using tilemap.SetTileData. :D

    I notice that the tutorial mentions tilemap.SetTile() as a convenience method to update a tile, but the method doesn't exist. Has it been removed from the API?
     
    Last edited: Nov 19, 2017
  8. Woofo

    Woofo

    Joined:
    Aug 10, 2017
    Posts:
    3
    I created a simple brush extension for a use case of mine and figured I'd share it in case it's helpful for anyone else. CreativeSpore is authorized to incorporate/modify this code to add to SuperTilemapEditor if desired.

    My specific use case was to paint a wall border around a room, so that the wall edges would hug the interior. Basically what I wanted was something similar to the CarpetBrush, but instead of having the carpet edges autotile outward with grouped tiles, I wanted the wall edges to autotile inward around ungrouped tiles.

    It turned out that this was easily done with only a handful of modifications to the CarpetBrush script in CalculateNeighbourData and GetSubtiles. All that was necessary was to change the autotiling_X bools to check for an existing tile that the current tile is not autotiling with (I renamed to bordering_X to reflect the new behavior), and to invert all references to s_neighIdx and the s_showDiagonal bools, since we want to tile the edges inward instead of outward. There are likely more efficient ways to implement some of these changes, but I left them as simple as possible for clarity.

    Here are the ordered code locations that changes are required to create BorderBrush.cs from CarpetBrush.cs. I've also attached my BorderBrush.cs and BorderBrushEditor.cs so you can try it out without having to manually edit these yourself (I got the OK from CreativeSpore to do this). Note that the editor required no changes aside from renaming CarpetBrush to BorderBrush. You could argue that the interior corner hint label is less clear now, but you set up the tiles in the editor the same way you would for CarpetBrush. In most cases, you probably want the Autotiling mode to be Self.


    Changes required in CalculateNeighbourData:
    Changes required in GetSubtiles:

    Here is the completed brush in action: https://i.imgur.com/zJ21wjn. Low quality mp4 conversion to gif oops, hopefully you can still see it.

    If not, here's a picture example of how it's set up in the inspector using some tiles included in the STE package:



    and here's how it looks drawing around some water tiles. There's some perspective issues since these tiles weren't originally drawn with the intention to tile this way, but you can see the idea.



    UPDATE:

    I pretty quickly ran into the case where I wanted to draw a foreground border wall around a background interior, but since each layer is a different tilemap, it wouldn't find the tiles to border around. Now if the brush's tilemap has a TilemapGroup as parent, it grabs the group's tilemaps and runs the check on all of them, so if any of the maps have a valid ungrouped tile, it's considered a bordered tile. Make these changes to the attached files to add this functionality:

    BorderBrushTilemapGroupUpdate.png
     

    Attached Files:

    Last edited: Feb 2, 2020
    CreativeSpore likes this.
  9. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    The method was not removed but renamed. In the current version it is called SetTileData but the new version will come with this change:
    Code (CSharp):
    1. /// <summary>
    2. /// Set a tile data at the local position
    3. /// </summary>
    4. public void SetTile(Vector2 vLocalPos, int tileId, int brushId = Tileset.k_BrushId_Default, eTileFlags flags = eTileFlags.None)
    5. {
    6.     int gridX = BrushUtil.GetGridX(vLocalPos, CellSize);
    7.     int gridY = BrushUtil.GetGridY(vLocalPos, CellSize);
    8.     SetTile(gridX, gridY, tileId, brushId, flags);
    9. }
    10.  
    11. /// <summary>
    12. /// Set a tile data at the grid position
    13. /// </summary>
    14. public void SetTile(int gridX, int gridY, int tileId, int brushId = Tileset.k_BrushId_Default, eTileFlags flags = eTileFlags.None)
    15. {
    16.     uint tileData = ((uint)flags << 28) | (((uint)brushId << 16) & Tileset.k_TileDataMask_BrushId) | ((uint)tileId & Tileset.k_TileDataMask_TileId);
    17.     SetTileData(gridX, gridY, tileData);
    18. }
    They were renamed to avoid parameter collision with the methods using the parameter "unsigned int tileData".
     
  10. ookami007

    ookami007

    Joined:
    Nov 8, 2017
    Posts:
    12
    I just bought your tile editor to import from Tiled but when I do, the tiles in Unity are off. In Tiled, the map looks seamless, but in Unity there are nasty looking seams.

    Here's the Tiled version:



    And the Unity version in Play mode.



    What am I doing wrong?

    I thought I followed the video of importing but apparently I made a mistake - multiple times. This is the main reason I bought it - to import Tiled.

    Notice too that the larger objects are cut off or missing entirely, like the tree and the bushes.
     
  11. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    Hi there,

    Use the attached patch to fix the issues and let me know if you still have problems with the tile size.

    For the seams, you can fix it by adding an Inner Padding of 0.2 or 0.4
    upload_2017-11-24_11-57-53.png
    You can also use the Atlas Editor Window and add some extrusion pixels (1 or 2)
    upload_2017-11-24_11-59-42.png
     

    Attached Files:

    Shilo likes this.
  12. Andrew122222

    Andrew122222

    Joined:
    Jul 8, 2012
    Posts:
    28
    I'm currently on Super Tilemap Editor version 1.4.3, and I would like to update to the latest version (1.4.6). However, it seems like it breaks quite a bit. Sure there are a couple of name changes like Tilemap to STETilemap, but generally speaking, my entire maps disapear and I need to recreate tilemaps (and possibly brushes) and redraw everything.

    How do you recommend updating to a new version while minimising the damages to my older maps that I've already created?

    I'm using Unity 2017.1.0f3 (64-bit) if it helps.

    Thanks for your time.
     
  13. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    Don't worry, you won't loose anything if you follow the steps in this post:
    https://forum.unity.com/threads/released-super-tilemap-editor.387330/page-18#post-3241654

    Don't forget to make a backup of everything just in case.

    If you need more help let me know.
     
  14. Lightrail

    Lightrail

    Joined:
    Apr 12, 2013
    Posts:
    37
    I have a couple of questions about the colliders in STE.

    1) For the Edge Collider 2D option, how does this work? It appears in the editor that the colliders are still using polygon colliders and I don't see an edge collider option when editing colliders in the tile viewer. Just None, Full and Polygon. I assume this just means the edges connect to each other but don't form a polygon? It would be nice to have a 2 point minimum for simple platforms.

    2) I use the Platform Effector 2D component for one way collision and was wondering if there were a way to add effectors to STE colliders. Right now I create a STE and add a game object with an edge collider and a Platform Effector 2D and line it up but that means inconsistencies between tile collisions as I'm pretty much eyeing it. Does STE support effectors and I'm missing the option somewhere?

    Anyway, I really enjoy STE and as someone before on this thread said, it's way better than Unity's atm.
     
    ystomy and CreativeSpore like this.
  15. ookami007

    ookami007

    Joined:
    Nov 8, 2017
    Posts:
    12
    I downloaded the patch and also used the padding option. It's MUCH better but there are still some "artifacts".

    See the lines near several items... vertical and horizontal on different items.

    Also, I'm unclear, are the colliders supposed to come in automatically, or is that a manual process.

     
    Last edited: Nov 26, 2017
  16. Andrew122222

    Andrew122222

    Joined:
    Jul 8, 2012
    Posts:
    28
    CreativeSpore likes this.
  17. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    You can change the collider type in the Collider tab of the tilemap inspector:
    upload_2017-11-27_12-48-38.png

    If you choose 2D colliders, you can also choose between Edge or Polygon colliders. Don't confuse it with the Polygon mode in the tile property window:
    upload_2017-11-27_12-51-25.png
    Here Polygon is basically telling the tile have a list of vertices used to generate the collider. For optimization there is a Full collider option that is faster than polygon if the collider is enclosing the full tile.
    So choosing Polygon you can add/remove and move vertices in the tile shape.

    To use PlatformEffectors you can make the tilemap chunks visible activating this option:
    upload_2017-11-27_12-59-39.png

    Then you can select the chunk (should be a children object with a name like 0_0 or -1_0, the numbers are the coordinates of the chunk)
     
    Lightrail likes this.
  18. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    To remove the lines try using the Inner Padding property, or use extrusion. What values did you use?

    About the colliders, you have to define what tiles has colliders. You can do it directly in the scene view. Check this video tutorial to see the process:
     
    Last edited: Nov 27, 2017
  19. Lightrail

    Lightrail

    Joined:
    Apr 12, 2013
    Posts:
    37
    Thank you! This answered my questions!
     
    CreativeSpore likes this.
  20. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    Sorry for the inconvenience. I try to make all new version compatible with the previous ones, but in this case I think it's related with a change in the name of the class Tilemap to STETilemap. This change was necessary for compatibility with Unity 2017 but it causes some issues in the update.
    Check this post with a list of steps to update the tool properly:
    https://forum.unity.com/threads/released-super-tilemap-editor.387330/page-18#post-3241654

    Let me know if you still need help after following the post instructions.
     
  21. Unusual-Cadence

    Unusual-Cadence

    Joined:
    Aug 12, 2015
    Posts:
    42
    Hello!

    I have found an interesting bug: I changed the color space of my game to be 'Liner' rather than 'Gamma', but now in the Tilemap palette everything is showing up as black (but looks fine when painted)! Do I need to refresh or regenerate a cached texture somewhere so I can see which tiles I am picking? :)
     
  22. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    I tried to change the Color Space to Linear and I see the tiles look darker but not black.
    upload_2017-12-1_17-2-2.png
    I tried this using Unity 2017.3.0b6. Maybe it's a bug related with the version you are using. What version is it?
    The tiles are rendered using this GUI method GUI.DrawTextureWithTexCoords so maybe it's related with that.

    I found this:
    https://forum.unity.com/threads/gui-texture-colours-are-off.185806/

    It looks like see it darker is normal unless you uncheck the sRGB property of the texture settings:
    upload_2017-12-1_17-9-19.png
     
  23. Unusual-Cadence

    Unusual-Cadence

    Joined:
    Aug 12, 2015
    Posts:
    42
    Ah that fixed it, thank you! :)
     
    CreativeSpore likes this.
  24. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore So I am having trouble trying to set the order in layer and not sure if I am trying to do this correctly. I have a script that updates the order in layer like this:

    Code (CSharp):
    1. SpriteRenderer.sortingOrder = Mathf.RoundToInt(transform.position.y * 100);
    So I put this on a prefab and then attach that prefab to the specific tile that I want to have this on (a tile in which the player should appear behind of) however this does not give me the desired effect.

    Am I doing this wrong?
     
  25. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    I am not sure what could be wrong. Are you using the same sortingLayer for the tile prefab and the player?
    Also, are you using the component TileObjectBehaviour in the tile prefab? In that case you need to check the property
    ChangeSpriteOnly or the sortingOrder and sortingLayer will be changed to be the same as the tilemap.
     
  26. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore So I was actually getting an error about SpriteRenderer not being a component on the object so I tried to add the TileObjectBehaviour script but that still did not work, here is a gif of the issue:

    Brief rundown of what I am doing:
    1. showing a sprite (not using the timemap editor) with the sort order script and how it works properly (with inspectors)
    2. showing the same sprite with the timemap editor and it not working properly (with inspectors)
    3. showing how changing the timemap's order in layer to the value of the prefab shows the correct result

    ScreenFlow.gif

    If there is any other information I can give you please let me know.
     
  27. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    I am not sure watching the gif what is your setup, but I will try to guess the answer.
    For what I see, you are trying to add tiles in the tilemap with a sorting script that changes the sorting order according to the Y position, so the player is rendered behind when it cross the pivot.y position that is in the center.

    If that is right, you need to use a prefab with the TileObjectBehaviour component and SpriteDepthBehaviour attached to these tiles so they are created as a separate gameObject. It doesn't matter if you change the sorting layer and sorting order of the tilemap, becuase it will be the same for all the tiles in the tilemap and not based on it's Y position.

    What I am not sure is why it is not working after you used a prefab for the tile to be created as a different gameObject. Maybe you didn't attach the prefab to the tile?
    Try following these steps:
    1. add a gameObject to the scene (rename it to SortingTile or any other name)
    2. Attach the TileObjectbehaviour component and your component SpriteDepthBehaviour (you don't need to set the sprite, but set the sortingLayer and sorting order if needed)
    3. Drag the gameObject to the ProjectView, to create a prefab
    4. Select the tileset or tilemap and right click over the tile in the tile palette (to open the Tile Property Window)
    5. Go to the Prefab tab in the Tile Property Window and drag or select the SortingTile prefab to the Prefab property field.
    6. Now paint the tile in the scene and you will see an instance of the tile is created as a children of the tilemap
    This way it should work.
    You can reuse the same prefab for any tile because the TileObjectBehaviour just create a sprite for the tile were it is attached and assign it to the SpriteRenderer so a prefab is enough for all tiles in the palette.

    I hope this time it works ;)
     
  28. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore So I think I fixed it and might know why it was happening but just wanted to confirm with you. I decide to undo everything I did and followed your list and that worked as expected. As I was looking to figure out what was different it was the fact that originally I had checked the "Show Tile With Prefab" when attaching the prefab. I did this as before when prototyping a different game, if I added a prefab to a tile, that tile would not show up without that checked so I thought I needed that here too.

    My guess if that because I added the TileObjectBehaviour to this tile (which I did not do with the other prototype), that behaviour handles rendering the tile so basically with both the TileObjectBehaviour attached and the "Show Tile With Prefab" checked, it was rendering 2 tiles, one with the correct order in layer and the other not, is that correct?

    Thanks for the help.
     
  29. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore So 2 things have arise with using TileObjectBehaviour / Attached Prefab:

    1. It seems like the weird display issue of the tile lokking detached breif come back when I attach a prefab with TileObjectBehaviour (not sure if TileObject behaviour has anything to do with it). I fixed this before by adding the 0.5 inner padding to the tile map but not sure if by using the prefab, if the inner padding no longer works. To show the issue

    WITH PREFAB (BAD):
    bad.gif
    WITHOUT PREFAB (GOOD):
    good.gif

    2. Is there a way to get the prefab game object when a collision happens on the tile. The game object of the collision seems to be the tile itself and not the prefab which is what I need. I can add a collider to the prefab and get it that way but not the collider of the tile in the tilemap. Not sure if this is as designed.
     
  30. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    Exactly, I didn't include the step Uncheck "Show Tile With Prefab" because it is unchecked by default, but if you use the TileObjectBehaviour you don't need to render the tile. Good to know where was the problem, I thought it was already uncheked.
    As a tip, you can use Show Tile With Prefab when you have a prefab with no image, like a dangerous area were you take damage.
     
  31. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    To remove the seams, you can try enabling pixel perfect in a custom Sprite/Default material and assign it to the prefab sprite renderer. But in some version of Unity I found Pixel Perfect also create seams in some cases. So another option would be increasing the size a little.
    Anyway, a Pixel Perfect camera would be a better option. If found this interesting article:
    https://blogs.unity3d.com/es/2015/06/19/pixel-perfect-2d/

    About the tile collisions. The tile itself has no colliders, the collider data is used to generate a tilemapChunk collider (a tilemap is divided in several tile chunks). So when you collide a tilemap collider you really collide one of the chunks. You can guess the collider you have collider if you get the tile using the collision point position like:
    Tile tile = tilemap.GetTile(contactPosition);
    int tileId = Tileset.GetTileIdFromTileData(tilemap.GetTileData(contactPosition));
     
    Last edited: Dec 7, 2017
  32. Hunkofsteel

    Hunkofsteel

    Joined:
    May 13, 2015
    Posts:
    26
    Hi, I just bought the asset, and I'm using Unity 2017.2.0f3.

    1) The rouge-like scene does not work. Gives an error when I run it.
    Not too sure how to fix it myself, so I can only refer to you.

    2) Is it possible to rotate tiles placed by Random Brush? I tried the shortcuts ("," and "."), but it seems to just rotate between the random tiles.

    3) Where can I access a tutorial or a place where I can learn how to create a custom brush properly? I want to create a Wall Brush that just has 3 slots (because my wall has 3 pixels), that would autotile with a floor group. Looking through some of the brushes's script (specifically road brush and carpet brush), I can't tell how to shape my GetSubtiles() and my Refresh(). In fact, the other functions that I can override I'm also frankly not too sure.

    4) I'm curious if there is a brush that allows an extendable size similar to the way painting works when you drag over the palette. It would be better for me to explain what I want to do. I currently have a 4x4 tile that I want to be part of the floor (just skinning it). What I want to do is to use the random brush to create the floor, so that it has all the jazz of nice and cool stuff all over it. Concurrently, when there are 4x4 tiles together, it could automatically form up and create the 4x4 tile. So what I believe I need to do is to create a custom brush for that. Still, I'm not really sure how.

    Honestly, great job with the asset. Its way above what Unity currently offers! However, a lot of stuff I had to go and figure out myself. Reading the manual and watching the tutorials did not really help me out as much as I had hoped. For example, I'm still stuck on the line artifacts issue. Upon extruding/padding the image, it just totally throws the Tile Palette in the Tile Set off. Its a good thing I'm still in the experimentation stage, and my artists have not created anything yet. Before they do, I need to know what kind of limitations they need to be working around, and inform them. Again, great job!
     
  33. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    Hi there!

    I have attached a patch to fix the rogue-like scene. It should work fine after applying the patch.

    Random brushes cannot be rotated by using "," and "." but you can rotate the tiles using the tile properties when you and editing the random brush.

    upload_2017-12-15_15-2-58.png

    I couldn't understand the question 3. Did you mean your wall has 3 tiles instead of pixels? I am going to create a tutorial to create a custom brush and let you know when it's finished. Anyway, if you take the Road Brush as template it should be easy creating your own brush.
    About your question, Refresh is called each time you place a tile using that brush in a tilemap and the tilemap is Updated calling UpdateMesh or Refresh. UpdateMesh will refresh the brush tile only once and Refresh will force the refresh.
    Each time a brush tile is refresh, the Refresh method is called. This method includes information by parameter of the tilemap calling the refresh, the grid position of the tile being refreshed and the tileData.
    To understand the tileData you can check this tutorial:
    https://creativespore.com/2017/10/23/understanding-tiledata/

    So in the Refresh method you return the new tileData for that tile back to the tilemap. In case of the Wall Brush, it checks the neighbor tiles (using the grid position as reference) and changes the tileId data for the tileData before returning it back, changing the tile displayed in the tilemap.

    GetSubtiles is returning an array of 4 tileData, one per each corner of the tile. It is used for the Carpet brush to create a tile made of 4 different tiles. When rendering the tile, each tileData will be used to render only a portion of the tile and each postion will be one of the 4 corners the tile is divided. Probably you won't need implement this method for your Wall brush.

    About question 4, I am not sure if you want to use a pattern of 4x4 tiles to paint the floor. If that is the case, you can select 4x4 tiles and use the fill tool to fill the floor with that patter. You can also use a random brush in the pattern.

    To remove the seams, try first adding some inner padding to the tilemaps. Use a value of 0.2 or 0.4. In most cases it fix the issue and it's simpler than extrusion.

    Also, I recommend you to check this tutorial about how to create a game using STME:
    https://creativespore.com/2017/12/0...h-super-tilemap-editor-temple-of-doom-part-1/

    The first part will teach you the basics to create a tileset, a tilemap and some brushes using autotiling groups.
     

    Attached Files:

  34. a98flo

    a98flo

    Joined:
    Jun 16, 2017
    Posts:
    4
    Hey. How can I use the fill toll in my own script?
     
  35. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    Hi there,

    First, follow this tutorial to understand tile data:
    https://creativespore.com/2017/10/23/understanding-tiledata/

    Then, you can use these methods to fill your tilemap:
    Code (CSharp):
    1.  
    2. STETilemap tilemap = GetComponent<STETilemap>();
    3. int mouseGridX = TilemapUtils.GetMouseGridX(tilemap, Camera.main);
    4. int mouseGridY = TilemapUtils.GetMouseGridY(tilemap, Camera.main);
    5.  
    6. // Fill starting at mouse position using the tile with id 5
    7. FloodFill(tilemap, mouseGridX, mouseGridY, new uint[,] { { 5 } });
    8.  
    9. // Fill starting at mouse position using the brush with id 5
    10. FloodFill(tilemap, mouseGridX, mouseGridY, new uint[,] { { 5 << 16 } });
    11.  
    12. uint[,] tilePattern = new uint[,]
    13. {
    14.     {1, 2, 3},
    15.     {4, 5, 6},
    16.     {7, 8, 9},
    17. };
    18.  
    19. // Fill starting at mouse position using the tile pattern:
    20. // |1|2|3|
    21. // |4|5|6|
    22. // |7|8|9|
    23. FloodFill(tilemap, mouseGridX, mouseGridY, tilePattern);
    24.  
    25. // Fill starting at mouse position using random tiles from pattern:
    26. FloodFill(tilemap, mouseGridX, mouseGridY, tilePattern, true);
    The flood fill will stop filling when reaching the tilemap bounds. Change the tilemap bounds with tilemap.SetMapBounds or trough the tilemap inspector view.

    I added some cases, but if you need more help with an specific case let me know.
     
    a98flo likes this.
  36. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,437
    Any news on exporting to native unity tiles? I like to see this option in order to use super tile map editor to work with others in a project and use super tilemaps to author and unity tiles for future safekeeping.
     
  37. a98flo

    a98flo

    Joined:
    Jun 16, 2017
    Posts:
    4
    Wow thank you for the quick and detailed answer! <3
     
    CreativeSpore likes this.
  38. a98flo

    a98flo

    Joined:
    Jun 16, 2017
    Posts:
    4
    Hey can you explain how the OnTriggerEnter function works with the SteTilemap Component? I have checked in the SteTilemap Component the IsTrigger variable, but unfortunatelly the OnTriggerEnter2D functions doesn't get called in my own script. :(
     
  39. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    Did you set the collider type to 2D or 3D?
    You also need to specify what tiles should generate a collider.
    You can set if a tile generates colliders in the Tile Property Window or directly in the Scene View when you select the Collider Tab.
    upload_2017-12-21_11-48-43.png

    Also, don't forget that to detect a trigger colliders at least one of the gameObejects involved in the collision needs to have a rigidBody.
     
  40. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    Still working on other features. It could take a while to consider that option.
     
  41. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
  42. fede1324

    fede1324

    Joined:
    May 22, 2017
    Posts:
    1
    Hi there

    I was wondering if this asset has a similar feature as the "terrain" in tiled, because my designer is really used to use it.

    And my other question is, How the tiled import works? can I import a
     
  43. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    Hi!
    I think your email was cut in the tiled question.
    About the terrain feature, it doesn't work like in Tiled, but there is a TerrainBrush but it is experimental.
    You can set different tiles per each combination.
    upload_2017-12-28_11-1-23.png

    About Tiled import, it works first creating a tileset from a tmx file. When you create an atlas, it will take all tiles in the tmx to create an atlas texture will all the images.
    Once you have the tileset, you can load the maps in the Scene using the tileset.
    What it doesn't support is objects, tile animations, and other special features in Tiled. Just tiles snapped to a rectangular grid (nor isometric nor hexagonal).
    Here you can see a video with all the process:


    If you have any other question don't hesitate to ask.
     

    Attached Files:

  44. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    New version of Super Tilemap Editor v1.4.7 available!

    Changelog v1.4.7:

    • ADDED experimental TileDataAttribute
    • CHANGED TileObjectbehaviour now has two static methods DoOnTilePrefabCreation and GetOrCreateSprite to be called from custom classes
    • CHANGED Asset/Create/SuperTilemapEditor menu priority to 50
    • CHANGED when a tileset is created, if a texture2D was selected, this texture will be assigned as atlas texture and the name of the tileset will the be name of the texture
    • IMPROVED TileObjectBehaviour using a cache of Sprites to save memory
    • FIXED null exception related with Brush Mask when creating a new tileset with no brushes in Unity 2017.3
    • FIXED sprite null error in TileObjectBehaviour when cached sprite is nulled after destroying atlas texture
    • FIXED Invalid Collider Array warning when generating tile colliders
    • FIXED tiles are now not stretched to fit the grid cell of a tilemap, instead they keep their aspect ratio
    • FIXED namespace issues when using the tool with other CreativeSpore tools
    • FIXED PathfindingBehaviour invalid cast error (displayed in the Roguelike demo scene when clicking on the map)
     
  45. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    @CreativeSpore If I have an X and Y position in which I know a tile with a prefab has been placed, is it possible for me to get the game object of the prefab instance (in order to access the a component on that prefab)? I know I can use GetTile() to get the prefab itself but I need to be able to access the prefab instance, not the prefab.
     
  46. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,186
    Right now it is not possible because the list of objects is private, but it could be possible to create a method to access the instance created at some tilemap position. Could you send an email with this request? I will send you back a patch as soon as I create the method so you can use it before the next update is released.
     
    Lars-Steenhoff likes this.
  47. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
  48. ThrakaAndy

    ThrakaAndy

    Joined:
    Nov 21, 2013
    Posts:
    3
    This is pretty awesome! I just bought it and it's working well. When do you think you'll get to part 2 of the tilemap game tutorial? Object-to-object interaction is the missing link for me right now.

    To get the player (from your tutorial article) to be blocked by a wall I tested if the collider I added to the prefab hits the Walls layer collider. Is this the correct way to do it?

    Code (CSharp):
    1. if (Input.GetKeyUp(KeyCode.LeftArrow))
    2. {
    3.     RaycastHit2D[] objects = new RaycastHit2D[20];
    4.     int results = Collider.Raycast(Vector2.left, objects, cellSize.x);
    5.  
    6.     if (results != 0)
    7.     {
    8.         for (int i = 0; i < results; i++)
    9.         {
    10.             var tilemap = objects[i].collider.GetComponentInParent<STETilemap>();
    11.  
    12.             if (tilemap.name == "Walls")
    13.             {
    14.                 // character hit a wall
    15.             }
    16.         }
    17.     }
    18.     else   // move player left a tile
    19.         transform.localPosition = BrushUtil.GetSnappedPositionCenter(new Vector2(transform.localPosition.x - cellSize.x, transform.localPosition.y), cellSize);
    20.  
    21. }
    Here is a new helper method for converting grid positions and local positions. These help me move prefabs around.

    Code (CSharp):
    1. /// <summary>
    2. /// Gets both the X and Y local position of a grid X and Y position according to the center of a tile.
    3. /// </summary>
    4. /// <param name="gridX">The tile X postion.</param>
    5. /// <param name="gridY">The tile Y position</param>
    6. /// <param name="cellSize">The size of a tile.</param>
    7. /// <returns>The center coordinates of a tile as a local position.</returns>
    8. public static Vector2 GetGridXYPositionCenter(int gridX, int gridY, Vector2 cellSize)
    9. {
    10.     return new Vector2(
    11.         gridX * cellSize.x + cellSize.x / 2,
    12.         gridY * cellSize.y + cellSize.y / 2
    13.     );
    14.  
    15. }
    16.  
    17. /// <summary>
    18. /// Gets both the X and Y local position of a grid X and Y position according to the top-left of a tile.
    19. /// </summary>
    20. /// <param name="gridX">The tile X postion.</param>
    21. /// <param name="gridY">The tile Y position</param>
    22. /// <param name="cellSize">The size of a tile.</param>
    23. /// <returns>The top-left coordinates of a tile as a local position.</returns>
    24. public static Vector2 GetGridXYPosition(int gridX, int gridY, Vector2 cellSize)
    25. {
    26.     return new Vector2(
    27.         gridX * cellSize.x,
    28.         gridY * cellSize.y
    29.     );
    30.  
    31. }
    32.  
    33. /// <summary>
    34. /// Gets both the X and Y coordinates of where a local position is on a tilemap.
    35. /// </summary>
    36. /// <param name="position">The position to convert.</param>
    37. /// <param name="cellSize">The size of a tile.</param>
    38. /// <returns>The X and Y coordinates.</returns>
    39. public static Vector2Int GetGridXY(Vector2 position, Vector2 cellSize)
    40. {
    41.     return new Vector2Int(
    42.         Mathf.FloorToInt((position.x + Vector2.kEpsilon) / cellSize.x),
    43.         Mathf.FloorToInt((position.y + Vector2.kEpsilon) / cellSize.y)
    44.     );
    45. }
     
    Last edited: Jan 7, 2018
    CreativeSpore likes this.
  49. MetaMythril

    MetaMythril

    Joined:
    May 5, 2010
    Posts:
    150
    @CreativeSpore is there any way to prevent the Parallax Factor from being applied in the scene view? I have multiple "rooms" in the scene and moving myself around the scene view gets incredibly distracting as the layers begin to skew far outside the bounds of their rooms.
     
  50. Andrew122222

    Andrew122222

    Joined:
    Jul 8, 2012
    Posts:
    28
    I was about to ask the same thing.