Search Unity

Official 2D Tilemap Extras 2.0 released for Unity 2021.1

Discussion in '2D' started by rustum, May 10, 2021.

  1. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    I guess we would like to have more feedback on it first? Eg. Does it suit your needs, is it easy to use, is it simple to set up?

    If you have any feedback on the Layer Brush, do let us know!
     
  2. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    I am the coder and my friend is the level designer so he is the main user of this brush. I just found it because he really needed it as we have several tilemaps and it takes a long time for him to move all the tiles on each map. He hasn't used it yet (as I just found it) and will use it in the next month.

    My first experience with it just testing it to see if it would work for him:

    It suits the need perfectly. It grabs all the tiles, no matter the layer, and moves them while maintaining our rule tiles. Without it, it takes much longer to edit a tilemap with multiple layers.

    It is extremely simple to use. I don't know what else to say about it. You select and move ;). It is also easy to setup as there really is no setup requirements that I can see. You simple select the brush and move the tiles you want!
     
  3. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Thanks for the feedback! If you have more details when you use it, do let us know!
     
    MousePods likes this.
  4. gPerry

    gPerry

    Joined:
    Nov 27, 2013
    Posts:
    21
    I am not the one you were replying to, but I just wanted to say that I agree with this, and to add that I hope you extend it to the GameObject/Prefab brush. Having to constantly switch back and forth between game objects to use the brush is not convenient.

    In my use case, I am building a platformer with a variety of different objects and categories - items, hazards, special platforms, interactables. It would be great if these could be put in a palette in the same way as the normal tiles, so that I can quickly select objects and paint them on the grid.

    At the moment, there is a list in the GameObject brush that only seems to accept a single item. Clicking the + does not add more items, nor does changing the Cells value.

    I am using 2020 LTS, with 2D Extras 1.8.1-preview, so it may be different on 2021/3.0.0.
     
  5. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Hi, this is the correct behaviour, although the UX is certainly not helpful here. To add or change the number of items, please change the Size below instead. The Cells value is single dimensional, compared to Size, which makes it difficult to whether to extend to painting dimensions horizontally or vertically. You could also pick more than one cell of GameObjects to expand your Brush as well.
     
  6. gPerry

    gPerry

    Joined:
    Nov 27, 2013
    Posts:
    21
    I think I understand now. The list of Cells is tied to the Size property, allowing you to place multiple objects at once in a grid pattern. Still, this doesn't seem like a very intuitive approach, and it doesn't solve the main issue which is that we would want to be able to select from a list of several potential prefabs/gameobjects.

    For example, I'm making a tile based platformer game. I use the standard tile palette to lay out my level tiles, picking different tiles from the palette and painting them onto the tilemap. Then I add a tilemap layer for my items, and I switch to the gameobject brush to start placing my interactive items on the grid. Now I have to drag in a new prefab from the project every time I want to add a different object type to the scene. I have at least ten different object types, so I end up switching frequently while working on levels.

    If used as it currently seems to be intended, I would have to repopulate this list of elements every single time I wanted to add some items to the grid. It would end up being more effort than simply placing them manually.

    Personally, I would expect this tool to allow me to build a palette of objects, just like the level tiles, and pick from them at will to start painting on the active layer. You could even create arrangements of objects to be painted at once using the filled box tool.

    However, looking at the documentation, it does appear that this feature is more intended as a demonstration for other developers of what can be done, rather than an end user feature.
     
  7. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    The intention is not to select from a list of potential GameObjects outside of the initial setup. Instead, we hope that users would populate the Tile Palette with the desired placement of GameObjects and Prefabs. After the population is done, users can pick and paint from the Tile Palette directly instead of setting up the elements in the Brush Inspector.

    The following is a video of how it can be done:


    The Tile Palette is populated with a GameObject Brush selection from the SceneView. The GameObjects can be picked from the Tile Palette and then painted onto the SceneView.

    Let us know if this works out for you or if you have any feedback and suggestions about this!
     
  8. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    361
    In the video demo you have 2 configurations: (1) small cube + big cube; and (2) small cube + big sphere. It would be better if we can save these configurations into 2 brushes and be able to switch between them just by clicking on the brush icons.

    Maybe we can utilize Presets rather than invent another data structure?
     
  9. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    You could have something similar to this by creating different GameObject Brush assets. This would require you to change the GameObject Brush script a little. You can retrieve the source code from https://github.com/Unity-Technologies/2d-extras and place it in the Packages folder of your project.

    1.
    In GameObjectBrush.cs:

    Code (CSharp):
    1.    
    2. [CustomGridBrush(true, false, false, "GameObject Brush")]
    3. public class GameObjectBrush : GridBrushBase
    4.  
    to:

    Code (CSharp):
    1.    
    2. [CustomGridBrush(false, true, false, "GameObject Brush")]
    3. public class GameObjectBrush : GridBrushBase
    4.  
    This will show each GameObject Brush asset in the Brushes Dropdown of the Tile Palette. You will be able to choose between different Brushes with their own configurations.

    2.
    Add the following to an editor script, an example can be found in BrushMenuItem.cs:

    Code (CSharp):
    1.  
    2.         [MenuItem("Assets/Create/2D/Brushes/GameObject Brush", priority = 0)]
    3.         static void CreateGameObjectBrush()
    4.         {
    5.             ProjectWindowUtil.CreateAsset(ScriptableObject.CreateInstance<GameObjectBrush>(), "New Game Object Brush.asset");
    6.         }
    7.  
    This will display a menu item for creating the GameObject Brush in the Assets menu. You will be able to create GameObject Brush assets and rename them appropriately for selection.

    Hope this helps!
     
  10. Zephus

    Zephus

    Joined:
    May 25, 2015
    Posts:
    356
    So, I've been working with the Tilemap system on a small game for a few weeks now, and I honestly have to say, that I'm close to giving up. The entire system is not fun to work with, extremely finnicky and has so many workflow issues that I'm considering just switching to Tiled and import the maps from there.

    I've tried to give helpful feedback quite a few times here in the forums, on the product roadmap and via mail. I'm also constantly reading about the exact same issues I'm having from other people, but it has been months, if not years, and there haven't been any improvements at all. I'll just say it, because I feel like it needs to be said: the entire Tilemap system needs a complete rework from the very ground up. Like scrap the entire UI, probably large parts of the underlying systems, and start over.

    I realize this is completely unreasonable, but those are my feelings after working with it for some time. I don't see any other way to fix this system. Small improvements, like moving the brushes to the scene view, can be made, but that doesn't fix the major workflow problems in the slightest.

    I would be extremely happy to give you detailed feedback with examples on what exactly is wrong with the current system. I could probably write an entire essay about those issues to be honest. I just don't know where to turn with this. I want the Editor to become better for 2D games, but I feel like feedback is not really taken into account at all.

    --------

    Take the issue of swapping tilesets for example that has been discussed in the forums already. Currently the 'hierarchy' works like this: Image -> Sprite -> Tile -> Tile Palette

    If I set this up and then decide to create a snow version of my tileset with tiles in exactly the same places, I don't have any way to tell Unity to just use the new image with all of the same settings. Because the tiles are using sliced sprites and not the spritesheet itself. Which means I also have to re-do all of the collisions. And then I'd need to swap out each sprite in those tiles separately. For rule tiles I need to go through the entire list of extremely small images to select the new sprites.

    This entire issue, and a lot of others, stem from the fact that a Tile is a separate asset that is referencing a sliced sprite. Meaning I can only swap out individual sprites. When in fact, I just want to swap out the Image itself.

    I can swap out the file on the hard drive and everything works exactly how I want - why can't this just be in the Editor itself? I want a single field that says "Source Image", and when I change the image the entire tilemap changes. Tiles, Tile Palette and Rule Tiles. This works flawlessly in other programs, like Tiled (which I honestly think you should take a look at). This is the reason why I'm advocating for a complete rework. I think the entire underlying system hinders the progress towards an actually good tilemap system.

    I'm sorry for the long post, but I think you can tell I've gotten a bit annoyed with Tilemaps.
     
    Last edited: Jan 9, 2022
    waishan and NotaNaN like this.
  11. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Sorry to hear about this and we would like to hear your feedback on how to improve the Unity Editor and the workflow for the Tilemap system. You are welcome to share it here or message us privately about it.

    I know that you have previously shared your issue with swapping Textures for Sprites in Rule Tiles. We do plan to improve this, but unfortunately, as with many things, this remains in our backlog...

    If you have more issues you would like to bring up, please do share them or bring them up again if we have missed them! Also, this request is open to anyone as well!
     
    Zephus and NotaNaN like this.
  12. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    I'm thinking about using the tilemap package in my next game. The only thing holding me back so to speak is the blurry micro-postage stamp previews for pixel art tiles.

    Whats the best way to get this issue under the radar of Unity? Could it be considered a bug? The current situation is largely un-usable for pixel art tilemap game development in Unity.

    Again for reference, this is the current experience of tile selection, these are at full zoom: Screen Shot 2021-10-29 at 14.37.31 (1).png

    Which then appear blurry in the tile editor:
    Screen Shot 2021-10-29 at 14.37.20 (1).png
     
    Last edited: Jan 17, 2022
    NotaNaN likes this.
  13. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Thanks for emphasizing on this. We have this in our backlog as a feature to improve the preview of such Sprites. We will try to bump this up if possible!
     
    NotaNaN likes this.
  14. Cheese_Eater420

    Cheese_Eater420

    Joined:
    Sep 23, 2021
    Posts:
    1
    Apologies if this has already been asked and I missed it, but is there a solution to rule override tiles not working with rule tiles? From my understanding rule overrides are there to blend with the existing rule tiles you put in and act like variations, but my rule overrides have just been acting like another, separate rule tile.

    upload_2022-2-6_2-23-28.png
    Here's an image where I've selected the rule override, but the two sets aren't combining. I have selected the initial rule tile in the inspector for the override and I can't for the life of me seem to find any other resources that explain this.
     
  15. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    The RuleOverrideTile itself does not blend with existing RuleTiles, such as the one it is overriding. It acts as a variant that allows you to modify some of the data of an existing RuleTile instead.

    We do have an example of a RuleOverrideTile that does what you need at https://github.com/Unity-Technologi.../Assets/Tilemap/Rule Tiles/Rule Override Tile , with a demo scene.

    Let us know if that example works out for you!
     
  16. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,514
    This request isn't specific to tilemaps necessarily but I find myself often wanting this exact thing in that context, so I'm making the request here: add a secondary search box to pre-populate asset searches if the "Memory Checkbox" is checked.

    memory.png
    If you've typed something in the white box and clicked the Memory Checkmark, the next time you search it'll prepopulate the search field with that string.

    To the right, there's an example context in which this feature would be very useful. Let's say there's 30 shapes that I'm plugging into a rule tile. The sprites follow a naming pattern. Each time I click to assign a sprite, it's back to square one (an empty search box) despite knowing I want assets with a particular prefix. It's annoying to type manually or Ctrl+V.

    With this feature, it would mean that it automatically brings up a subset and I can immediately click on something right away, or I could further narrow that subset by typing ("_1" or "_subcategory_3").

    This saves typing and clicks for repetitive tasks.

    The additional search field doesn't need to appear until the Memory Checkbox is turned on to keep things tidy.
     
    Last edited: Feb 7, 2022
    Xiangting_Su and NotaNaN like this.
  17. Xiangting_Su

    Xiangting_Su

    Unity Technologies

    Joined:
    Sep 22, 2020
    Posts:
    253
    Hey @Lo-renzo, thanks for your feedback! Interestingly, the pre-populate filter/visual query you described sounds really similar to the new Object Picker window another team is working on (which they are building on top of the Search window framework). We've reached out to them and passed on your feedback.

    They've replied saying that the feature is still under development but it is a known-request, so they are trying to get it done quickly to enable it for users! I for one, am super looking forward to it and they said they'll update us as soon as there's an ETA.
     
    NotaNaN and Lo-renzo like this.
  18. jacobhouston_unity

    jacobhouston_unity

    Joined:
    Mar 5, 2018
    Posts:
    6
    Hello, with animated tiles: is there any way to update the custom physics shape each frame? It's currently stuck on the first frames shape.
     
  19. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Hi, that is not possible right now. Could you share how your Animated Tile works such that you would need a physics shape update on each change? Thanks!
     
  20. jacobhouston_unity

    jacobhouston_unity

    Joined:
    Mar 5, 2018
    Posts:
    6
    It's a beach tilemap, the waves rise and fall on the shore. I'd like the player to only walk on the sand while the water is out, and be pushed back by the water.
     
    Xiangting_Su likes this.
  21. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Thanks for the information! We will consider adding an option such that the physics shape will be updated as the Sprite in the Animated Tile changes. However, the processing cost for updating the physics shape can be high, which why we do not have this option right now.
     
    jacobhouston_unity likes this.
  22. FluffyDoggoOfficial

    FluffyDoggoOfficial

    Joined:
    Nov 28, 2019
    Posts:
    1
    Just curious, but will the 2D Tilemap Extras be ported to Unity 2020, and will there be a feature to generate the auto tiles seen here from a map like below?
    upload_2022-3-11_13-13-8.png
    I know Fang Auto Tiles from the asset store does this, but I was wondering if this functionality would be built into this package.
    Thanks!
     
  23. Xiangting_Su

    Xiangting_Su

    Unity Technologies

    Joined:
    Sep 22, 2020
    Posts:
    253
    Regarding Autotiles, this is definitely something we would like to consider especially since there have been so many users requesting for a simpler Rules Tiles set-up. We have heard all of your feedback and have gone into super early R&D.

    In the meantime, feel free to share any more feedbacks/requests related to Autotiling or Rule Tiles here. For example, what are some of the things you guys find particularly useful in other Autotile solutions or if you were to nitpick, what would you guys have preferred they done differently? :)
     
    NotaNaN likes this.
  24. kayisoftDev

    kayisoftDev

    Joined:
    Jun 11, 2019
    Posts:
    8
    Hello
    I'm using Unity 2020 LTS, since our project is for production, and we can't consider using 2021 yet

    Currently we are limited to version 1.8.2 from this package in unity 2020
    are you planning to support version 2 for unity 2020 in the near future?

    Best regards
     
  25. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    For Unity 2020 LTS, we will support any issues with the Tilemap Extras and try to include any new features into this if possible.

    Right now, the only difference between the 1.8.x-preview and 2.2.x versions in the Unity Package Manager is in the Tile Inspector UI where data is shown in a ReorderableList. This is due to API changes for the ReorderableList between Unity 2020 LTS and Unity 2021.x. The functionality for both packages are the same so far.

    Let us know if you have any concerns or if you see a difference between the versions for 2020 LTS and 2021.x.
     
  26. kayisoftDev

    kayisoftDev

    Joined:
    Jun 11, 2019
    Posts:
    8
    Thank you for your kind response

    Yes we noticed a bug in 2020 LTS with 1.8.x-preview that got solved in 2021 with with 2.2.x

    When using Rule Tiles with isometric grid
    we get some gabs in the tilemap while drawing on borders

    upload_2022-3-17_9-45-8.png
    (when we fill the cell with red circle, some gabs appears as shown in the picture)


    after tons of tests, we tried the 2021 with 2.2.x and the problem is solved there
     
  27. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    That's interesting! We will check this issue out, thanks!

    If you can, could you share your RuleTile with us or file a bug using the Unity Bug Reporter?
     
  28. agelvik

    agelvik

    Joined:
    Nov 6, 2015
    Posts:
    23
    Hey,
    Any plans on adding Sprite Mask for Tilemap?

    My current workaround is creating an object containing a Sprite Mask, then applying it to my Rule Tile. This seems to be what most people do these days, but this makes my scene very heavy if I were to ex. zoom out.
    Would you happen to know of a different workaround that is less performance heavy?
     
  29. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Hi, this is in our backlog for features to implement.

    Unfortunately, to workaround this, you could implement a shader for the TilemapRenderer that would do the masking, but that would work outside the SpriteMask system. We will check out the performance issues to see how we could improve this!
     
    agelvik likes this.
  30. CoolJosh3k

    CoolJosh3k

    Joined:
    Dec 3, 2016
    Posts:
    145
    I've started using animated tiles, but have a question. When setting the speed of the animation, what exactly is that? Is it FPS and the same no matter if the vsync changes or the fixed time step changes? Would it run faster for someone with a 120Hz display?

    I'm assuming it works such that it is the number of FPS and does not run at a different speed if enviroment factors change.

    I'm using version 1.8.2 in Unity 2020.3.32f1 btw; incase something with this changed in later versions.
     
  31. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    The speed of the animation refers to the number of animation frames per second for the animation. A value of 1 would mean that the Animated Tile will switch to the next Sprite in sequence every second, while a value of 10 would mean that it would switch every 100 milliseconds.

    This should be the same regardless of vsync or the refresh rate of the display. Some Sprites may be skipped if a game update frame takes too long. For example, if a value of 1000 is used (a Sprite switches every millisecond), while a game update frame is 16 milliseconds, the animation would skip to the latest Sprite and not switch 16 times.
     
  32. IgorArnaut

    IgorArnaut

    Joined:
    Nov 15, 2021
    Posts:
    39
    I have two questions. How do I add methods (OnTriggerEnter2D) into an Animated Tile?

    Can I make a sprite in Animated Tile last longer despite having set minimum speed. I have set minimum speed to be 8 and I want to make a sprite last 16 frames.
     
    Last edited: May 6, 2022
  33. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    This will not work as you expect as a Tile is not a MonoBehaviour but is a ScriptableObject. You would need to create your own MonoBehaviour that would track triggers on a TilemapCollider2D and calculate where the trigger was triggered based on the location of the other collider.

    This would depend on your game's frames per second. If your frames per second is 60, then as the animation speed is the number of animation frames per second, you would put the minimum and maximum speed as 60/16 to get a constant 16 frames.
     
    CoolJosh3k likes this.
  34. IgorArnaut

    IgorArnaut

    Joined:
    Nov 15, 2021
    Posts:
    39
    This is not what I meant for the last one. I want to make individual nodes have different frame durations despite having set maximum and minimum overall speed, just like in Animation tab.
     
  35. CoolJosh3k

    CoolJosh3k

    Joined:
    Dec 3, 2016
    Posts:
    145
    Sorry for the late reply, but thanks a ton for letting me know about that. I was worried, but had a feeling it might work be like that.
     
  36. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Right now, you would have to create different Animation Tiles and set the speed that you want for that particular animation. You could use
    Object.Instantiate
    with the original Animation Tile, set the speed for the clone and place it on the Tilemap using
    Tilemap.SetTile
    .

    The animation speed is currently not exposed through user scripts. We will put this in the backlog for consideration. Thanks!
     
  37. theboxfriend

    theboxfriend

    Joined:
    Jun 7, 2021
    Posts:
    1
    So I'm building a proc generated game where rooms are instantiated at runtime, each rooms is made up of some tilemaps and some of them have Rule Tiles with an attached GameObject. Every single Rule Tile that has a GameObject attached is spawning a second copy of the GameObject at 0,0,0 relative to the room at runtime only in a build. This issue is not reproducible in the editor but has been happening since before 2022 was released. I did some searching and it seems I am not the only one experiencing this issue. I did submit a bug report regarding this issue, but I'm wondering if there is a possible workaround for this issue. Right now I'm checking the objects' position in Awake() and just destroying it if its localposition is 0,0,0 but this feels hacky and honestly shouldn't even be necessary
     
  38. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Hi, could you post the case number for the bug report? Thanks!
     
  39. IgorArnaut

    IgorArnaut

    Joined:
    Nov 15, 2021
    Posts:
    39
    Can you at least make tiles (even rule tiles) that I can add SpriteRenderer, Animator, RigidBody2D, BoxCollider2D and other scripts to?

    I don't want to create prefabs, because I find these very redundant, and I don't want to put these components to a whole TileMap.

    EDIT: To be specific, I want to make a tile that will e.g. change its color when the player character steps on it (enters its box collider), trigger player's animation and decrease player's health periodically.
     
    Last edited: Aug 8, 2022
  40. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,514
    @IgorArnaut Tiles/Tilemaps are specifically to render simple things. They have a very low memory footprint and can be rendered more cheaply than many SpriteRenderers. To make tiles more complex would defeat their purpose. You want a gameobject / prefab for something like you described. You can attach a prefab to a tile if you want if you want a convenient way to paint prefabs on a grid. It's often best to use tiles where you can, but prefabs for anything more complicated, requiring custom data/logic/components.
     
  41. IgorArnaut

    IgorArnaut

    Joined:
    Nov 15, 2021
    Posts:
    39
    Can you make Rule Tile tab look better? I don't like the current list view, especially if you make many Rules. I have to scroll down if I have more than 16 Rules. A grid view would be better.

    Can you make Animated Tiles be dragged directly into Rules instead of making animation per Rule?

    EDIT: I am making a Rule Tile and it's so tedious to look at especially if you have 47 Rules, and you can't even select multiple Rules.
     
    Last edited: Aug 31, 2022
  42. Xiangting_Su

    Xiangting_Su

    Unity Technologies

    Joined:
    Sep 22, 2020
    Posts:
    253
    @IgorArnaut, thank you for all of your great feedbacks! Yes, this is definitely something we would love to look into and it's already in our backlog. We want to provide users with a more artist-friendly way to set up these Tiles quicker and in a more scalable view where it's easier to see the Tiles relationship with one another.

    Could you help me understand a bit more as to what you are trying to make here? A visual might be helpful in this case too. Thanks!
     
  43. IgorArnaut

    IgorArnaut

    Joined:
    Nov 15, 2021
    Posts:
    39
    What I have said. Adding sprite by sprite into rule tile to make an animation makes the Tab longer. upload_2022-9-1_19-51-8.png
     
  44. Xiangting_Su

    Xiangting_Su

    Unity Technologies

    Joined:
    Sep 22, 2020
    Posts:
    253
    Right, thanks for the screenshot! I get what you mean now. When creating an animated Rule Tile, you would like to be able to drag in different Animated Tiles (that have been previously set up) directly into the different Rules of a Rule Tile. Meaning instead of doing so Sprite by Sprite all over again, is there a way we could reuse the Animated Tiles with Rule Tiles to speed up the workflow.

    This sounds like a reasonable request. Let me feedback this to the team. Thanks for letting us know!
     
  45. gooby429

    gooby429

    Joined:
    Aug 13, 2019
    Posts:
    135
    just wanna suggest you add the RandomTile :) not sure why its not included from the original old repo but its def useful
     
  46. velezoso

    velezoso

    Joined:
    Apr 28, 2021
    Posts:
    2
    I can't see 2D Tilemap extras preview package in version 2020.3.40f1

    I am using Unity 2020.3.40f1 and have enabled preview packages but I can't see the package.

    But if I use Unity 2020.3.34f1 and have enabled preview packages I still can see the package.

    What is happening?
     
  47. JVemon

    JVemon

    Joined:
    Jul 30, 2017
    Posts:
    18
    Could you add overloads to Tilemap.SetTiles that accept Spans instead of just arrays? Or at least overloads that take a start index and length.
     
  48. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Thanks for the feedback! We will add this to our backlog and see if this is possible.
     
  49. danyaegoist

    danyaegoist

    Joined:
    Nov 8, 2017
    Posts:
    7
    For my game, I need to generate a large terrain size in 2d. I use Tilemap and generate layers through seed and noise, set the filled and the chance of this or that object appearing.
    The essence of the mechanics is that I draw only the visible part of the space and take all the data from the seed. And when the player starts running in one direction, I paint everything in front of him and clear everything behind him using the SetTiles method.
    And with an interesting camera setup for the player, I get 4k cells. And it causes GC memory cleanup spikes.
    And I think that this is due to the fact that in all methods that can change tiles in a tile map, the "Tile" type is boxed as "Object".

    According to the algorithm, I collect all the changed tiles (some are cleared, some are filled) and apply the changes like this:

    tilemap.SetTiles(posArray, tileArray);


    I was looking for any method that won't box tiles. But they all do it. Including the TileChangeData structure.

    Code (CSharp):
    1. /// <summary>
    2.     ///   <para>Sets an array of Tiles at the given XYZ coordinates of the corresponding cells in the Tilemap.</para>
    3.     /// </summary>
    4.     /// <param name="positionArray">An array of positions of Tiles on the Tilemap.</param>
    5.     /// <param name="tileArray">An array of Tiles to be placed.</param>
    6.     public void SetTiles(Vector3Int[] positionArray, TileBase[] tileArray) => this.SetTileAssets(positionArray, (UnityEngine.Object[]) tileArray);
    7.  
    8.  
    9. /// <summary>
    10.     ///   <para>Fills bounds with array of Tiles.</para>
    11.     /// </summary>
    12.     /// <param name="position">Bounds to be filled.</param>
    13.     /// <param name="tileArray">An array of Tiles to be placed.</param>
    14.     public void SetTilesBlock(BoundsInt position, TileBase[] tileArray) => this.INTERNAL_CALL_SetTileAssetsBlock(position.min, position.size, (UnityEngine.Object[]) tileArray);
    15.  
    16. TileChangeData.cs
    17.  
    18. /// <summary>
    19.     ///   <para>The Tile to set on the Tilemap.</para>
    20.     /// </summary>
    21.     public TileBase tile
    22.     {
    23.       get => (TileBase) this.m_TileAsset;
    24.       set => this.m_TileAsset = (Object) value;
    25.     }
    26.  
    27.    public TileChangeData(Vector3Int position, TileBase tile, Color color, Matrix4x4 transform)
    28.     {
    29.       this.m_Position = position;
    30.       this.m_TileAsset = (Object) tile;
    31.       this.m_Color = color;
    32.       this.m_Transform = transform;
    33.     }
    I have few questions:
    1. Am I doing something wrong?
    2. Why are tiles boxed in all API methods? Is it really necessary? Or can it be changed/fixed?
    3. Is it possible to add some kind of tile pooling system to the tilemap? So that it does not recreate beyond what is necessary and use what is available to the maximum? And all this under the hood?
     
    Last edited: Mar 19, 2023
  50. GamerXP

    GamerXP

    Joined:
    Mar 22, 2014
    Posts:
    78
    I was trying to use GridInformation class to save some extra data about tiles.
    Thing is.. data is lost after reload. You forgot to add [Serializable] attribute to your internal structs.
    I'm surprisged nobody noticed it before - it was in the pacakge since forever.