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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[RELEASED] Super Tilemap Editor

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

  1. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    696
    These are special tiles (they are all going to be breakable, some will probably regrow, stuff like that) even though they are going to be quite common. I did test loading a map of 500x500 with 60000 of these prefab tiles and the performance seemed good. I am sure as I add more stuff, I will need to be able to optimize it but I am hoping this library has ways to render only certain checks of maps based on where the player is (so that it is not rendering anything that is no where near the user but no need in worrying about that stuff right now.
     
  2. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    These warnings have been fixed in the next release. Thanks for telling about this ;)
     
  3. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    In that case you could create a brush for this.
    This brush would need to draw the bottom tile and the top tile in the Refresh method:
    Code (CSharp):
    1.  
    2. public uint TopTile;
    3. public uint BottomTile;
    4.  
    5. // this will display the preview of the tree in the tile palette
    6. public override Rect GetAnimUV()
    7. {
    8.     Rect topTileUv = Tileset.GetTile( Tileset.GetTileIdFromTileData(TopTile) ).uv;
    9.     Rect bottomTileUv = Tileset.GetTile(Tileset.GetTileIdFromTileData(TopTile)).uv;
    10.     return new Rect(bottomTileUv.position, new Vector2(bottomTileUv.width, bottomTileUv.height * 2f));
    11. }
    12.  
    13. public override uint Refresh(Tilemap tilemap, int gridX, int gridY, uint tileData)
    14. {
    15.     tileData &= ~Tileset.k_TileDataMask_TileId; // remove previous tile id
    16.     tileData |= BottomTile;
    17.  
    18.     tilemap.SetTileData(gridX, gridY + 1, TopTile);
    19.     return tileData;
    20. }
     
  4. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    The sprite renderer is a component so what you can do is create an sprite from a tile Id to be set in the sprite renderer. You can see how to do this is the component TileObjectBehaviour. This component will create a sprite from a tileId to be set in the Sprite Renderer.
    In the next version there will be also a TileObjMesh component to do the same but using a Mesh instead of a SpriteRenderer.

    About the middle mouse button, you can press Q to activate the hand tool or press the Hand icon to move the scene. Alt, Control and Shift are already used for special actions while drawing.
     
  5. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    What happens instead? Could you attach an screenshot or console log?
    Also, could you check the max size of the texture in the import settings?
    Your texture is bigger than the default 2048 size, so maybe there is the problem.
     
  6. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    The render optimization is automatically done by Unity.
    Other things like updating tile animations, etc, are also updated only when the tile chunk is being rendered.
    If you find any performance issue let me know and I will try to find a solution.
     
  7. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    343
    There appears to be a bug in the update..

    I can no longer set the brushId of the tile, the brushId is in the tiledata in the call to SetTileData(), but when I fetch the tile again, the brushId is 0

    So in my function, I am setting the tile, after update mesh, the brush id is still there.
    When I call CheckAgain, the brush id becomes 0.

    #UPDATE#
    I tried setting the brushId with a carpet brush, it works.
    When I set the brushId with a random brush, it becomes 0!
    This worked before update.

    Code (csharp):
    1.  
    2. function {
    3.    ..
    4.    tileData.brushId = (int)bush;
    5.    map.SetTileData (x, y, tileData.BuildData ());
    6.    map.UpdateMesh ();
    7.  
    8.    rawTileData = map.GetTileData (pos);
    9.    tileData.SetData(rawTileData);
    10.    Debug.Log ("AFTER" + tileData.brushId + "" + pos); //this is correct id
    11.    StartCoroutine (CheckAgain (pos));
    12. }
    13.  
    14. // the brush id is 0
    15. IEnumerator CheckAgain (Vector2 pos) {
    16.     yield return new WaitForSeconds (1);
    17.  
    18.    uint rawTileData = map.GetTileData (pos);
    19.    tileData.SetData(rawTileData);
    20.    Debug.Log ("PLACE" + tileData.brushId + "" + pos);
    21.  
    22.    yield return new WaitForSeconds (1);
    23.  
    24.    rawTileData = map.GetTileData (pos);
    25.    tileData.SetData(rawTileData);
    26.    Debug.Log ("PLACE" + tileData.brushId + "" + pos);
    27. }
    28.  
     
    Last edited: Dec 20, 2016
  8. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    This has been changed in version 1.4.2. But the previous functionality is there commented, at the end of the method Refresh in RandomBrush.cs.
    This has been changed to allow using animated brushes as random tiles. An animated brush need the brush id of the animated brush in order to work, so the random brush id needs to be changed.
    If this is not done also for non animated tiles, eventually all tiles will become animated tiles if you draw a region with random brushes.
    If you think the old functionality should be activated in some cases, I will add a way to decide how it should work depending on the needs.
     
  9. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    New version of Super Tilemap Editor 1.4.2 has been released!

    v1.4.2 Changelog:

    • Added support for UNITY 5.5
    • Improved performance and reduced memory allocation when updating the tilemap
    • Added more painting tools: line, rectangle, filled rectangle, ellipse and filled ellipse
    • Flood Fill now supports a pattern from a tile selection
    • When a tilemap group is selected, the tilemap list will be display in the SceneView for a direct access
    • When a tile has attached a prefab, the prefab preview will be displayed in the tile palette instead of the tile
    • Added "Optimize Atlas Import Settings" button in the tileset inspector view to automatically change the import settings of the atlas texture to the recommended settings.
    • Added FindTilemapByName to TilemapGroup to acces a children tilemap
    • Added index property to tilemap group to access a tilemap by index of by name: tmapGroup[index] or tmapGroup["tilemapName"].
    • Added TileObjMesh component (more optimized version of TileObjectBehaviour)
    • Added GetParamsFromTileData to TilemapUtils to get a paramter from a brush or a tile directly from the tile data.
    • Added IterateTilemapWithAction to call a System.Action for all cells in a tilemap
    • Added support for selecting animated brushes in random brushes
    • Random brushes now works in a different way. Once the tile is randomly selected, it paint the tile but loose the random brush connection, so copy and paste that tile will not draw a new random tile.
    • Selecting a tile in a tilemap with right click will select the tile istead of the brush is ALT is being hold
    • Fixed some null exceptions when removing the atlas texture from the tileset in a scene with a tilemap using the tileset
    • Fixed in Atlas Editor Window, when adding padding to an atlas, the color between tiles was white with alpha, not transparent
    • Fixed instantiating tilemaps from a prefab was keeping the same Mesh reference for all instances. Now all instances will have its own Mesh.
    • Default tile size is now (32,32) when creating a new tilemap
    • Fixed moving the mouse over a tile parameter name field was unhighlighting the name field


     
  10. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    343
    So if I want to update the tilemap from code and set a particular tile as a random tile from the random brush and be able to fetch that brushid when reading tiles, how would I do that in this update (without altering/uncommenting code)? Or is that permanently gone (unless i uncomment that code)?

    I need to access the brushid of the tile before update any tile..
     
    Last edited: Dec 20, 2016
  11. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    It is permanently gone unless you uncomment the code.
    This is something tricky, because if the random brush id remains, then an animated brush couldn't be chosen in a RandomBrush, but the other option is to loose the random brush id after updating the tilemap.
    In your case you can take the brush id selecting it in the brush palette, and use that id. The problem is if you want to take the brush id from the tilemap.
    I will think about this to find a solution for both cases. Meanwhile you can uncomment the code.
     
  12. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    343
    I see. I have uncommented the code.

    The reason why I need brushId is because the code needs to determine what kind of tile it is. Instead of adding a "tiletype" param to every single tile, I am distinguishing this via the brushId that is used. I can add the param to each tile, but it gets way too annoying when i have over 200 tiles and managing it becomes error prone.

    This is my use case for brushid.
     
  13. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    In that case, I will add an option to decide the behavior of a Random Brush, using the previous behavior by default.
    So in the next version you won't need to change anything.
    I have attached the RandomBrush modified to work as before with an option to restore the support to animated random tiles. I will include these modifications in the next version.
     

    Attached Files:

    Last edited: Dec 21, 2016
  14. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    343
    But if I want the random brush to include animated brush and at the same time have brushId saved, that modification won't work?
     
  15. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    No, you need to choose between having support for random animated tiles or keeping the random brush id.
    Anyway I am still thinking about how to support both. The problem is, the animated tiles call the GetAnimUV method of a brush, so if the brush is the random brush, there is no way to know the animated brush because the random brush takes a random tile each time.
     
    Last edited: Dec 21, 2016
  16. Ryan-Hayle

    Ryan-Hayle

    Joined:
    Feb 16, 2014
    Posts:
    142
    Hi, I bought your asset yesterday for the TMX export feature. I have multiple 2048 image tilesets using 64px width and height. I followed your video, but I was unable get it to work as the asset seems broken. It would also be nice to know what the tmx exporter can and can not do and what your future plans are to improve it as the docs are lacking. I did message your website yesterday for some help. Thank you.
     
  17. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    Hi Ryan,
    I didn't receive any message yesterday about this issue.
    The problem is probably the textures of the tilesets are too big to create a Super Tilemap Editor tileset. When you export a TMX map, all the tileset textures are merged in a single texture, and there is a limit in the size of that texture or 8192.
    Is this the case? How many textures do you have?
    I'm working to remove this single texture per tileset limitation, but right now only a texture up to 8192 is allowed per tileset.
     
  18. Ryan-Hayle

    Ryan-Hayle

    Joined:
    Feb 16, 2014
    Posts:
    142
    It fails to work with even two 2048 image tilesets using 64px width and height.
    The tilesetAsset variable found in the CreateTilesetFromTmx function loses its values after the ImportTexture function has been called if I recall.
     
  19. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    I have been checking the importing code and I found some bugs when the texture atlas is bigger than 2048.
    I have fixed the bugs and tested with a test tiled scene with two tilesets using textures of 2048x2048.
    Try applying the attached patch and let me know if it works or if you find any other issue to fix it.
     

    Attached Files:

  20. Ryan-Hayle

    Ryan-Hayle

    Joined:
    Feb 16, 2014
    Posts:
    142
    Thank you, that's much better!
    Rather than calling AssetDatabase.LoadAssetAtPath would it not be better to create the tilesetAsset at this point, as it doesn't appear to be in use till then?

    Also why are the tiles not in order? e.g.
    id: 0
    id: 64
    id: 128
    ...
    id: 1984
    id: 32

    The create a Tileset approach/option does not have this problem.
     
  21. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    The AssetDatabase is a little tricky and not always work as expected. For example, for some reason after importing the texture asset, the tileset asset is nulled, but only sometimes. If you see in the code, I have a NOTE commentary about having the opposite issue if the tileset asset was created after the texture asset, in this case the texture asset is nulled.

    About the tile id order, you should use the tileviews created for each tileset so see the tileset properly. The (All) view will display the full atlas.
    upload_2016-12-23_16-20-49.png
     
  22. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    343
    I tried upping the tile map size from 200x200 to 256x256 and updating the map increased gc alloc by 20kb.
    It appears that the map size affects it.. digging into profiler it is from updating the colliders.

    Is it possible to optimize it so that the map size doesn't affect it? I want to be able to have bigger maps but not possible with the gc increasing..


    UPDATE*
    In line 52 of TileMapChunk, the if statement was commented out
    I uncommented it and it decreased 20kb of gc!!
    It appears that the getComponent inside was generating a lot of garbage and the aCollider2D length was always 0 in my case. The colliders were also still updating for me (using 2d edge collider)

    I don't know if it is safe to uncomment the if line, could you please verify?
     
    Last edited: Dec 26, 2016
  23. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    When you use the profiler in the Editor you could see some GC Allocations that won't be in the final build. This is the case as you can see in this link:
    http://answers.unity3d.com/questions/636278/should-getcomponent-generate-garbage-when-the-comp.html
    You shouldn't get this allocation in the build, but if you still see any GC allocation let me know.
     
    Last edited: Dec 26, 2016
  24. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    343
    I did some test and yes, it does GC allocation (this is profiling on the device)

    #code left untouched
    updating the map created 15kb of gc

    #uncommented the code
    updating the map created 10kb of gc

    I am updating the same map with the same changes in both tries (conducted the test multiple times and the tests with the if statement added back created less gc.
     
  25. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    I've been testing with a Windows Build. According to the CPU Usage there is a GC allocation, but according to the memory there is no GC allocation in the build, only in the Editor.
     
  26. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    In the last update I have changed the way the tiles with prefabs attached are displayed in the tile palette.
    Now if a tile have a prefab attached, the prefab preview will be displayed instead. In some cases this could be a problem for some users, so this will be changed in the next version to be optional, displaying the tile by default.
    Until next release is available, you can revert this change by applying attached patch or making a small change in the code.
    upload_2016-12-29_11-11-45.png
     

    Attached Files:

  27. Robosaur

    Robosaur

    Joined:
    Jan 21, 2014
    Posts:
    6
    Yo quick Q: How do you grab the properties of a tile at a specific location? Like, if you set custom parameters for tiles, how would you return them?
     
  28. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    You need to get the ParameterContainer for the tile or brush.
    To make it easy you can use the helper method TilemapUtils.GetParamsFromTileData:
    Code (CSharp):
    1. /// <summary>
    2. /// Get the parameter container from tileData if tileData contains a tile with parameters or Null in other case
    3. /// </summary>
    4. /// <param name="tilemap"></param>
    5. /// <param name="tileData"></param>
    6. /// <returns></returns>
    7. static public ParameterContainer GetParamsFromTileData(Tilemap tilemap, uint tileData)
    8. {
    9.     int brushId = Tileset.GetBrushIdFromTileData(tileData);
    10.     TilesetBrush brush = tilemap.Tileset.FindBrush(brushId);
    11.     if(brush)
    12.     {
    13.         return brush.Params;
    14.     }
    15.     else
    16.     {
    17.         int tileId = Tileset.GetTileIdFromTileData(tileData);
    18.         Tile tile = tilemap.Tileset.GetTile(tileId);
    19.         if(tile != null)
    20.         {
    21.             return tile.paramContainer;
    22.         }
    23.     }
    24.     return null;
    25. }
    26.  
    This method will return the parameter container from a tile or brush using the tiledata stored at certain tilemap position. You can use tilemap.GetTiledata to get this data from the tilemap (for a grid or world position).
    Then you can get the parameter value calling these methods from ParamterContainer:
    • GetIntParam
    • GetFloatParam
    • GetBoolParam
    • GetStringParam
    • GetObjectParam
    Or take the reference to the parameter with FindParam for a direct access.
    You can set the value using SetParam: ex: SetParam("HP", 67) or SetParam("Alpha", 0.5f) Remember to add the F at the end of a number to create or set a float parameter.
    You have other helper methods in ParameterContainer like AddValueToIntParam and AddValueToFloatParam

    By the way, you can use the parameters also for gameobjects with the attached package, using the component Parameters.

    Happy New Year!
     

    Attached Files:

  29. rubeng

    rubeng

    Joined:
    Apr 20, 2013
    Posts:
    58
    Hi @CreativeSpore is it possible to use carpet brushes but with subtiles disabled? subtiles never look good with our tileset, and they force us to check everything carefully since, in some cases it appears ok, but looks bad up close.

    Thanks
     
  30. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    If you want to use subtiles I could help you to make it work.
    Sometimes it could be because the InnerPadding value of the tilemap is set to a value different than 0. By default it's set to 0.1, but this will be changed in the next version to be 0 by default.
    Anyway, a CarpetBrush is like a RoadBrush if you are not using the subtiles. So you can use a RoadBrush instead.
     
  31. steddyman

    steddyman

    Joined:
    Apr 10, 2009
    Posts:
    253
    I've purchased this component today after reading the documentation (it looks great) but I cannot get it to work properly in Unity 5.5 on Mac OSX.

    I have created a TileSet with 16x16 sprites in a 96x64 image. From that I have created a TileMap and I am trying to paint with it. Nothing is displayed apart from a wide bounding box that expands as I paint. If I zoom all the way in (about 1/1000th the width of the camera Frustrum) I can see tiny purple squares that are barely visible, shown where the tiles should be.

    I have the pixels per unit set to 100 on the image (and clicked optimise) and have the Map Cell Size set to (0.16, 0.16). I've tried playing with this, even increasing the pixels per unit to 1, and the purple boxes get bigger but nothing is displayed.

    I originally created the project in 3D by mistake, then switched it to 2D mode in the GUI and in the Editor settings. This is driving me nuts.
     
  32. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    You can paint also using the 3D mode, but you need to focus the camera to the tilemap plane set by the rotation.
    Also, to change the size of the tiles you should change the Cell Size of the tilemap instead. The Pixels per unit set in the tileset is used only to set the initial cell size of a tilemap when it's created for the first time.
    Also, the camera sometimes is culling objects when you are zooming in/out. Double click over the tilemap object or press F when it's selected to focus the tilemap and fix this issue.
     
  33. steddyman

    steddyman

    Joined:
    Apr 10, 2009
    Posts:
    253
    Hi, I switched to 2D mode before even importing the asset. I have tried lots of different values for Cell Size, but it is still not visible in the viewport. Double clicking or pressing F makes no difference, I see the white outline of the bounds of the current Tile Map but nothing visible inside it.

    I had repurposed an old test project and deleted all the contents in the project folder. I just tried creating a new 2D project from scratch and it now works! Not sure what is up with the old project (upgraded from Unity 5.2) but clearly a project issue.

    Thanks for your help.
     
  34. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    I'm glad it's working now.
    As a tip, I usually work with different versions of Unity with the same project and most of the issues I have are fixed by removing the Library folder in the project root before opening the project with another version.
     
  35. steddyman

    steddyman

    Joined:
    Apr 10, 2009
    Posts:
    253
    Good tip to know. Thanks
     
  36. bitbiome_llc

    bitbiome_llc

    Joined:
    Aug 3, 2015
    Posts:
    58
    Finally back to working on maps! Just have to say I LOVE the new collider interface. The get tile method along with tile parameters also simplified map "edge" detection for pathing and targeting. Keep up the great work!
     
    CreativeSpore likes this.
  37. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    I'm glad you are back ;)
    I am working on new things for the next version. I hope you like it too!
     
  38. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    343
    Is there a toggle to make the collider merged per chunk instead of for the entire map?
     
  39. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    What do you mean? The tile colliders are merged per chunk.
     
  40. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    343
    Oh because I noticed that if I increase the map size, the time it takes to updateMesh increases. I thought it was updating the entire map instead of the chunk being worked on.

    But if colliders are merged per chunk, and updating the map only updates the affected chunk, why is performance getting slower as the map gets bigger? Shouldn't map size not be a variable since everything is in chunks?

    Is there a way to increase the map size without losing performance?
    Right now my map is 200x200, chunk is 10. I want to increase the map size a bit more but I start to see staggering when updateMesh is called.
     
  41. Kavex

    Kavex

    Joined:
    Jun 13, 2013
    Posts:
    2


    I'm trying to figure out why I have these lines, I'm sure it's something dumb I'm doing but my head is spinning.

    I have my group tiles on different order layers so why is it still clipping? FYI Love this asset so far

     
  42. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    I've been testing and I found out, the times increase slightly only for UpdateColliders, not for UpdateMesh, unless you mean the UpdateMesh in the Tilemap class, not the TilemapChunk class.
    The reason is a call to GetComponents when using 2D colliders done always, even if the chunk is not marked to be refreshed.
    I've added an "if(m_needsRebuildColliders)" and the times has been reduced again.

    upload_2017-1-10_10-21-15.png

    Other reason for this could be because 2D colliders have a bug in versions below 5.3.4p1 where the time to set the vertices of a collider is increased each time they are set. If this is the case, when you change the scene and reload it again you will see the times are reduced again until you start painting again.
    The only way to fix it if you need to use a version with this bug is disable the colliders while painting and enabling them after finishing painting. This is also a good tip when using 2D colliders to improve the painting performance.
     

    Attached Files:

  43. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    This is in the F.A.Q section of the manual :)
    Q: I see weird lines between the tiles in a tilemap?
    A: Check if the atlas texture used by the tileset have the filter mode different than None in the texture import settings. If you still see pixel artifacts between the tiles, try to disable Pixel Snap from "Tilemap\Renderer" and use the Atlas Editor to apply extrusion with a value of 1 or 2.
    You can also press the button "Optimize Atlas Texture Settings" in the Tileset inspector view

    The reason of this is not because the tiles are in the same layer, it's because depending on the camera position and because of float imprecision, sometimes a neighbor pixel of a tile is rendered.
    Inner padding can help you with this, but it will affect the tiles changing the size of the pixels a little. So it's better to use the Atlas Editor to apply a extrusion (extending the neighbor tiles around the tile a couple of pixels, so when this happens at leas the neighbor pixel has the same color.)
     
  44. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    343

    I tried adding the if and it helped a bit. So that one is good.

    When you mentioned disabling the collider, do you mean doing something like this?
    Code (csharp):
    1.  
    2. ...
    3. if (colliders == null) {
    4.    colliders = CurrentMap.GetComponentsInChildren<EdgeCollider2D> ();
    5. }
    6. for (int i = 0; i < colliders.Length; i++) {
    7.    colliders [i].enabled = false;
    8. }
    9. CurrentMap.UpdateMesh ();
    10. ...
    11.  
    I tried doing the above before calling UpdateMesh but it increased the GC by 2 times.

    And what about UpdateMesh in the tilemap class? Did you notice an increase GC/Time MS when map size increases?

    #update
    I updated to 5.4.4 and it didn't seem to make any difference, i guess it wasn't the collider2d bug you mentioned.
     
    Last edited: Jan 10, 2017
  45. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    When I mentioned disabling the collider, I mean setting the collider type to None:
    CurrentMap.ColliderType = eColliderType.None;
    CurrentMap.Refresh(false, true);

    But this is only useful while painting in the editor, so you don't need to make it through the code. Just setting None in the Collider section of the tilemap.
    I guess, you are modifying the tilemap in realtime while in play. In that case don't bother to disable the colliders, because you would need to re enable them anyway after the modifications.

    About the GC allocated, sometimes the GC is allocated in the editor, but not in the final build. It happens with some editor methods like GetComponent for example. In case of 2D colliders, I still need to remove some allocation made while generating the 2D collider segments. This is why I prefer to use 3D collider, they are faster to manage and to generate. But I have in my list improving this using a pool of segments or something to be shared between all the tilechunks during the generation of 2D colliders. Anyway, it should be a bug amount of GC, and it's located only to the modified chunk.

    Also I found out, this sentence:
    foreach(TilemapChunk chunk in m_dicChunkCache.Values)
    is generating more GC than this:
    Code (CSharp):
    1. var valueIter = m_dicChunkCache.Values.GetEnumerator();
    2. while (valueIter.MoveNext())
    3. {
    4.     TilemapChunk chunk = valueIter.Current;
    5.     ....
    6. }
    7.  
    I will change this in the next version.
     
  46. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    343
    I have been testing the game on an actual device, that is why it is concerning.

    Every time I update the map (200x200, 10 chunk size), there is a slight stagger. I am testing on a Samsung S5, not a particular new/old device. But there are a lot of users running on older devices which is problematic as I am experiencing performance issues (the slight stagger when updating map real time).

    I remember you mentioning that chunks are only updated if the chunk needs to be updated, so shouldn't a small chunk size reduce the number of tiles that needs to be updated (thus faster)? But it seems that the map size has an effect on this, so is there a way to remedy this?

    I will also try updating the foreach you mentioned above.
     
  47. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
    Besides the Ai, pathfinding etc... I am not sure that I completely get the difference between RPG map editor and Super tilemap editor. Does RPG map editor include the features of super tilemap editor? I am trying to decide which one to get and they almost seem like competing products (I tought they were from different authors until I heard the same song in the videos hehe).
     
  48. flipwon

    flipwon

    Joined:
    Dec 29, 2016
    Posts:
    179
    I am looking into purchasing a tile map editor and came across yours among others, just have a few questions before I make a final choice on my purchase. For context I am making a top down action adventure game in the vein of zelda or secret of mana.

    1. I'm planning on handling each room/screen as a separate object or "tile map" in your case, and was wondering how your tile maps are set up. Are they one object, where I can place two side by side and see them both present in my scene? I'm planning on deactivating tile maps you cannot access and preloading them when you're a screen away, transitioning into the next a la zelda. Although I'd like to make the full map in the editor side by side to see what I'm doing/connecting.

    2. How many draw calls can I expect per tile map? Are they rendered together as a single mesh?

    3. If I was to use things like barrels and objects as interact-able prefabs, am I able to place those in your editor or do I need to place them as children myself outside of your editor?


    I'm sorry if my questions are not clear, I'm new to unity and some of my terminology may be way off. Kind of hard to put in words but I hope it makes sense.

    Cheers!
     
  49. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    I think your performance issues could be related with a tilchunk size of 10, or maybe the way you are updating the tilemap.
    For example, if you add a tile where there is no tilechunks, a new tilechunk will be instantiated, and destroyed if there are no tiles left. That will take some extra time than if you just change a tile from a tilechunk.
    This is an example of a big tilemap, big enough to use 20x20 tilechunks with the size of 60x60 tiles each, profiling while in play mode (in edit mode there are some extra management):
    upload_2017-1-12_11-37-56.png

    The selected frame is one of the frames were I am drawing a tile in the top right corner, all of them inside the same tilechunk.
    In this example I am also using 2D colliders a the brown tile has been changed for a tile with colliders.
    upload_2017-1-12_11-46-10.png
    In this case there is a spike when I am adding tiles, but it's related with Physics2D.
    I have used the RoguelikeTileset by the way for these tests.

    By any chance, are you using the Refresh method to update the tilemap or the UpdateMesh method? Refresh will force all the tilechunks to be updated, UpdateMesh will only generate a new mesh for the modified tilechunks.
     
  50. CreativeSpore

    CreativeSpore

    Joined:
    Nov 6, 2014
    Posts:
    1,189
    Yes, they are different products. RPG Map Editor is focused on being an startup for RPG games using graphics resources compatible with RPG Maker VX. There are tons of free to use resources compatibles in webs like this one:
    https://vxresource.wordpress.com/
    So the tilemap editor in RPG Map Editor is focused to be like the RPG Maker editor, and make it easy to create a map.
    Also including the DirectionalCharacterAnimator to easily create an actor using a compatible spritesheet, and included a frameswork with AI behaviours, Player controller, vehicles, etc.

    Super Tilemap Editor was created to be only a tilemap editor for general purpose. But it doesn't include AI behaviour, pathfinding, etc, just features to help creating a game using a grid (you can use the editor also to place game elements using the grid, not just tiles).

    If you have a more specific question, don't hesitate to ask.
     
    tcz8 likes this.