Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

SpriteTile, a fast dynamic tile system (RELEASED)

Discussion in 'Assets and Asset Store' started by Eric5h5, Dec 11, 2013.

  1. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    Not missing anything, I just didn't implement that, sorry. I should replace the "make colliders" checkbox when importing TMX files with an option to have the tile defaults applied; that would make more sense. As a work-around, you can double-click a tile in the Level pane to select all tiles of that type, make sure the matching tile is selected in the Tiles pane, then click the Fill button in the selection controls or hit F. That would apply the tile defaults appropriately. Though I understand that would be annoying if you have a lot of tiles with trigger values that you want to apply.

    --Eric
     
  2. Toad

    Toad

    Joined:
    Aug 14, 2010
    Posts:
    296
    OK, thanks. Will look for the 'unsaved level' dot in future.

    Tested the NewLevel fix, and it works. Thanks for that.
     
  3. m_santoro

    m_santoro

    Joined:
    Apr 29, 2017
    Posts:
    3
    That should work pretty well for me, my maps aren't too complicated.
     
  4. Toad

    Toad

    Joined:
    Aug 14, 2010
    Posts:
    296
    Hi Eric, I'm trying to add a custom collider to a tile. The manual states that a Box Collider 2D can be used (as well as a Polygon Collider 2D), but when I try to assign a Box Collider 2D to a tile using the 'From Object' button I get an error message 'No Polygon Collider 2D attached'.

    Please could you see if you can replicate this on your side?

    Tried assigning a Polygon Collider 2D, and that works fine.
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    Indeed that does happen, sorry about that. I'll do an update, but you can also fix it in the editor source, in the TileControls script, where the last line of the ApplyCustomCollider function should have "collider.name" replaced with "(Selection.activeObject as GameObject).name". (If you're using the DLL and want to switch to source, make sure to read page 2 of the docs first.)

    --Eric
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    So:

    SpriteTile 3.1.2

    TileEditor Fixes:
    • Fixed error that occurred when applying box colliders as custom tile physics colliders.

    TileEditor Changes:
    • When importing TMX files, "Make tiles with the Collider option checked have colliders in the map after import" is now "Apply tile defaults after import". So all tile defaults, not just colliders (i.e. trigger, order, rotation) can be applied.

    Submitted to asset store.

    --Eric
     
  7. DreamPower

    DreamPower

    Joined:
    Apr 2, 2017
    Posts:
    82
    It seems that every time I update SpriteTile, it loses my tilesets. I still have the maps I made with it, but no tilesets to go with those maps (so I get a "Missing Tiles" dialogue when opening the editor). I then have to manually load the tilesets in the editor (the first time it happened I hadn't saved the tilesets I was using so had to recreate them from my collection of various tiles). Am I doing something wrong?
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    Sounds like the TileManager reference is getting disconnected from the SpriteTile/Resources/TileManager object. You can drag TileManager from the dll or source script onto the appropriate slot on the TileManager object to fix that.

    --Eric
     
  9. polarmagpie

    polarmagpie

    Joined:
    Nov 11, 2017
    Posts:
    4
    I have serious issue about the asset.

    I searched web to find the solution, but I stuck. Maybe you guys can show some mercy for me?

    After importing all files the asset offers, I found, not like the documentation, I can't find the "SpriteTile Editor" in Window menu.

    So I cleared the files and reimport it and nothing changed. I imported the packages from other projects of mine to practice, and there too the tap the document noted didn't appear.

    I also checked asset path, I put them in Assets/Plugins/* .

    My Unity's Version is 2017. 1.0f3.
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    Don't import all the files. If you do, the source package conflicts with the DLL. You can have the source, or the DLL, but not both. Presumably there's an error in the console.

    --Eric
     
  11. polarmagpie

    polarmagpie

    Joined:
    Nov 11, 2017
    Posts:
    4
    Uh Oh. I'm quite embarrassed now. Thanks.
     
  12. Toad

    Toad

    Joined:
    Aug 14, 2010
    Posts:
    296
    I'm having a problem with the latest version of SpriteTile (3.1.2) in both Unity 2017.1 and 2017.2 (on Mac OS 10.13.2) where the SpriteTile Editor isn't available to select from the Windows Menu.

    I've tried creating new, empty projects and importing SpriteTile on it's own and have the same problem.

    Any ideas?
     
  13. Toad

    Toad

    Joined:
    Aug 14, 2010
    Posts:
    296
    Just noticed that if I select the TileEditor DLL in the Project window the following error message is displayed in the Inspector;

    "Plugin targets .NET 4.x and is marked as compatible with Editor, Editor can only use assemblies targeting .NET 3.5 or lower, please unselect Editor as compatible platform."

    I've changed the Scripting Runtime Version in Build Settings to 'Experimental .NET 4.6 Equivalent' and restarted the Unity Editor. This seems to have resolved the issue, as the SpriteTile Editor now appears in the Window Menu.
     
    Last edited: Dec 10, 2017
  14. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    Oops, I had the .NET version in the TileEditor DLL set wrong. I've submitted a fix. Thank you for catching that.

    --Eric
     
  15. Toad

    Toad

    Joined:
    Aug 14, 2010
    Posts:
    296
    Thanks for the fix. Will look out for the update.
     
  16. jamiewhitephd

    jamiewhitephd

    Joined:
    Jun 8, 2012
    Posts:
    120
    Hi Eric,

    Is Sprite Tile working in Unity 2017.3.0? I created a quick test level file to load when the game starts and, as you can see from my attachments (screens 1 and 2), what is loaded is not what was created using the editor.

    EDIT:
    So I cleared ST and tried again (screens 3 and 4). I Created a new Tile Set and another new level file. This time, no tiles spawn whatsoever. The game objects are created but the renderer components are all empty.
     

    Attached Files:

    Last edited: Jan 14, 2018
  17. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    It does work in 2017.3...one of the editor scripts uses EventType.used instead of EventType.Used, but the auto-upgrader fixes it.

    --Eric
     
  18. jamiewhitephd

    jamiewhitephd

    Joined:
    Jun 8, 2012
    Posts:
    120
    OK, could you clarify which scripts you are referring to? I'm using the DLLs, not the source code.
     
  19. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    It's the TileEditor script. However the updater works with DLLs as well. Also make sure the Resources/TileManager asset still has the TileManager script/DLL associated with it. If not, drag it onto the slot.

    Screen Shot 2018-01-14 at 5.22.54 PM.png

    --Eric
     
  20. jamiewhitephd

    jamiewhitephd

    Joined:
    Jun 8, 2012
    Posts:
    120
    OK, thanks for the clarification. I checked the file you mentioned (see attached image) and the sprites are all there and seemingly correctly referenced. However, still, LoadLevel results in game objects with empty sprite renderers. Is there anything else I could be missing? I went over the quick start guide and followed it as advised.
     

    Attached Files:

  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    Are there any errors in the log? If you try the demos, do they work?

    --Eric
     
  22. codesushi

    codesushi

    Joined:
    Sep 27, 2014
    Posts:
    22
    Hello,

    I am working on a strategy game that will feature the game's viewport in the middle of the screen, surrounded by the menu. The menu will stay fixed while the player can scroll through the map in the game's viewport. See screenshot.

    What would be the best way to accomplish this with SpriteTile?
     

    Attached Files:

    • menu.png
      menu.png
      File size:
      24.1 KB
      Views:
      530
  23. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,004
    I have used sprite tile in the past but am not an expert with it.

    Assuming you move the camera to scroll across the map in free direction, I would
    - overlay the menu area with a non transparent GUI (edit: screen overlay, ie not affected by camera movement)
    - I think sprite tile also has a border feature, possibly that could be turned on to avoid drawing tiles that are covered, but I don’t think it will have a massive performance impact
     
  24. codesushi

    codesushi

    Joined:
    Sep 27, 2014
    Posts:
    22
    Thanks. I was trying to use a UI overlay using a Canvas and Image. But I'm unable to accurately measure the Image in world space in order to offset the SpriteTile viewport to not be covered by the overlay when scrolling-- I don't want the leftmost or rightmost tiles to be permanently obscured by the surrounding overlay/border.

    Another thing I tried was using a rendered texture for the game viewport, the same technique used for minimaps. The SpriteTile level's position would be offset so that it is never visible in the main camera. This may work though I would need to offset mouse coordinates when detecting clicked tiles in the game viewport. Also the raw image used will end up scaling down the game, an undesired effect. Is there a better way?
     
  25. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    It would be easiest if you used two cameras, one for the game part and one for the menu.

    --Eric
     
  26. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,004
    Oh yes, that’s a good suggestion ;)

    Did not think of it, although I used something similar (2 player same screen with 2 tile map cameras render side by side and the main camera rendering the space in between)
     
  27. codesushi

    codesushi

    Joined:
    Sep 27, 2014
    Posts:
    22
    Thanks. Not sure if I understand. Do you mean try the multi-camera feature in SpriteTile? Or do you mean using two cameras, one with a rendered texture and RawImage, with the RawImage nested in the menu border?
     
  28. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    None of that, just two cameras. The bottom camera covers the entire screen and renders the UI, the top camera is a subset of the screen and is for SpriteTile.

    --Eric
     
  29. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    SpriteTile 3.2 is out, with full Unity 2017.3 compatibility, and has been submitted to the asset store.

    --Eric
     
  30. m_santoro

    m_santoro

    Joined:
    Apr 29, 2017
    Posts:
    3
    I can't figure out how to totally unload the tilemap. When the player wins a game, I send them back to the Start screen, but the tilemap is still displayed. I would like to unload it and then once the player starts a new game load a new tilemap. Is there an easy way to do this that I'm missing?
     
  31. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    You can use EraseLevel().

    --Eric
     
  32. Logophil

    Logophil

    Joined:
    May 26, 2013
    Posts:
    2
    Hi, first of all thanks for the great work. I had some trouble using Eraselevel() and Loadlevel() though, I'm using a lot of colored tiles (using setcolor) and it seems using Eraselevel and Loadlevel still kept some of the original color data intact. Just wondering if you were aware of any issues in this area?
     
  33. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    I was not aware; thank you for pointing it out. I've fixed it for the next version. In the meantime you could use Tile.SetColorBlock to manually fix it, or if you'd rather have the updated source now, send me a PM with your invoice number.

    --Eric
     
  34. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    And here it is:

    SpriteTile 3.2.1

    Fixes:
    • If tile colors are being used, Tile.EraseLevel sets all tile colors for each layer to its ambient color.
    • If a level used tile colors, loading another level clears the on-screen tile colors.

    --Eric
     
  35. munnergep

    munnergep

    Joined:
    Feb 17, 2011
    Posts:
    13
    Is it possible to use self illum sprites with black ambient settings?
     
  36. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    Setting the ambient to black just sets all the tile colors to black; what are you trying to achieve?

    --Eric
     
  37. munnergep

    munnergep

    Joined:
    Feb 17, 2011
    Posts:
    13
    Luminous eyes in the dark, etc.
    Colors to black... it explains everything, thank you!
     
  38. Kaven-Co-Games

    Kaven-Co-Games

    Joined:
    Jun 3, 2014
    Posts:
    16
    Hello. I've been using SpriteTile for a lot of stuff and I really enjoy it.

    But recently I was working with a game that has a lot of tiles in the view of the camera, and I'm finding that when I zoom in and out its really causing some lag issues. I understand that spriteTile scales the amount of gameobjects needed to render a map down so that you only have the amount you need to render what is in view, but for some reason theres a huge bottleneck once I start reaching 140x140 tile view panes. Besides the initial generation There is no logic running in the game besides some simple camera panning, so the performance issues are entirely within spriteTile. Do you have any suggestions on how to cope with maps with a large amount of tiles in the camera view?

    Thanks
     
  39. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    I'm not sure why there would be a bottleneck at any particular size. Rendering-wise, SpriteTile doesn't do anything on its own, but it depends on Unity sprite batching, so there actually isn't a lot I can do. In general it's best not to have very large numbers of tiles in camera view with SpriteTile, given the sprite-per-tile approach, though of course the number of tiles in the entire level has no effect. Limiting the zoom-out would be best.

    --Eric
     
  40. Kaven-Co-Games

    Kaven-Co-Games

    Joined:
    Jun 3, 2014
    Posts:
    16
    I see. I found another solution in procedural mesh generation. By creating a large mesh and splitting each quad into different textures as it creates the visualization of a tilemap without the excessive need for gameobjects. Thank you though.
     
  41. ryanzec

    ryanzec

    Joined:
    Jun 10, 2008
    Posts:
    666
    @Eric5h5

    So I have a few question about SpriteTile
    • What is the state of the assets, I see it has not been updated since late April which I don't necessarily consider bad but just wonder if you basic considered the asset feature complete and only releasing bug or do you have future planned features?
    • Would you recommend this asset for building a game on the scale functionality / scale of Starbound worlds, biggest things being:
    1. Huge total world sizes (talking around 18 million tiles)
    2. Large amount of renderer tiles at once, I think Starbound does around 19K on screen and about 56K when counting the tile off screen (will provide screenshot of this)
    3. Completely destructible / build-able world (every tile can be destroy or built on)
    4. Multiples layer of tiles (I assume Starbound does this to be able to place a large number of tiles / object on top of a large number of background tiles)
    As for the screenshots I mention: this show the max default zoom level (each notch is 5 tiles:
    sb-max-defualt-zoom.png

    This is when I zoom out even further than normal with mod (which does make the FPS drop quite a bit as it was not designed to work at this level but it does show the edge of where stuff is rendered (at least horizontally):
    sb-max zoom.png
     
  42. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    At this point it doesn't have any known bugs and has most of the features I intended. Unity including a tile feature predictably reduced the market for this sort of asset. There have been some people preferring SpriteTile because of some issues with Unity's feature, but not enough to warrant major further development. In any case: 1) Yes. 2) No, it's not optimized for large numbers of very small tiles on-screen; huge numbers of tiles are a non-issue as long as the "window" doesn't have too many visible at once. 3) Yes. 4) Yes.

    --Eric
     
  43. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    2,960
    SpriteTile is pretty much the template for what we wanted out of the built-in system. It's had a good few years of showing how things are done :)
     
  44. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    Thanks, I'm about 95% happy with the design. :) I'm not sure I ever really managed to communicate the level of control, which was partially the result of years of seeing people (reasonably) wanting programmatic access to all Unity functions, and not liking editor-only stuff and black-box stuff. (And seeing devs respond "what's the use case for that" when people ask...I don't think it's necessary to ask that, since there's always a legit use case for pretty much everything. People will inevitably want to do crazy stuff with the API you would never have thought of, so just skip all that and make everything accessible from the start, is what I say....)

    --Eric
     
  45. tiggus

    tiggus

    Joined:
    Sep 2, 2010
    Posts:
    1,237
    Question on creating procedural levels at runtime - SetTile takes an index in the tileset, is there a builtin way to specify a sprite name in the tileset instead of index?

    Ie. if I want "wall_corner_dark" as opposed to "wall_corner_light" I have to build my own sprite name to index mapping(which I am doing with constants right now), or am I missing something. Love this asset still years later and it works great with the new Unity pixel perfect camera component from what I can tell.
     
    Last edited: Dec 12, 2018
  46. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    There isn't a built-in way, no.

    --Eric
     
  47. codesushi

    codesushi

    Joined:
    Sep 27, 2014
    Posts:
    22
    Hello,

    First, thanks for the excellent library and all of the support you've provided.

    I am taking advantage of Tile.CameraRotationX to create a Mode 7 type effect for my game. The problem is, I want to enable scrolling while also keeping the camera locked to that perspective. But things go awry when the camera moves, and the camera is not locked to the SpriteTile surface, and the background ends up in the frame. How can I achieve this?
     
  48. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    Hi, I'm not quite following what you're attempting. For example, if I set CameraRotationX to -20.0 in the Procedural Level example, it works as expected. (Also best in this case to change the AddBorder property of the level from 0 to 6 in order to get rid of the tile popping.)

    --Eric
     
  49. codesushi

    codesushi

    Joined:
    Sep 27, 2014
    Posts:
    22
    I am trying to get the level to scroll on keyboard movement, but with the camera rotation set to give it that Mode 7 type look.

    Yeah, I was seeing tile popping. Also, only part of the level is rendered and visible as the camera moves. There's some kind of culling of the level that takes place, which would work when scrolling happens without any kind of camera rotation. Which makes sense, since the whole level is never rendered all at once. It's just that the view bounds get messed up since the camera is no longer facing orthogonal to the surface where the level is rendering.

    I'll try modifying the procedural level example to see if I'm doing something differently, and will let you know.
     
  50. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,244
    Sounds like maybe you just need to increase the AddBorder value.

    --Eric
     
unityunity