Hello Guest

Author Topic: Tilemap, saving chunks for procedural generation.  (Read 3934 times)

Spidyy

  • Newbie
  • *
  • Posts: 1
    • View Profile
Tilemap, saving chunks for procedural generation.
« on: May 19, 2015, 02:47:02 am »
Hello there.

I'm starting to work on a kind of randomly generated RPG, and I'm trying to figure the "how-to" for the world map. As I see with the Tilemap editor, I could use the scratchpad data's to save each room/area/coridor/parts datas of my world. I would then set some rooms data (size, doors, etc), have them assembled using some procedural stuff, then fill the tilemap with the tiles of each rooms.

My issue comes from how the API of tilemap works. Right now, the perfect object for this stuff would be the tk2dTilemapScratchpad object, but it is in the UnityEditor namespace and used as an Utility object to build the map in Unity. I can't use it in runtime.

I would have two approaches for this. Either I massacre the existing code to get the tk2dTilemapScratchpad as runtime data I would then save in some ScriptableObject, or I redo my own "Room Data" object, with the same kind of datas than the scratchpad (array of int for the tiles, sorted in several layers) and write a custom editor for those Room Data, using the tk2dTilemapRenderer and brush. In other word, rebuild the editor for a new kind of objects to edit. :/

So here is my demand : would it possible to add an option to save/load the content of a scratchpad as a file object (.asset or custom) we could then push inside the tilemap (Tilemap.SetTiles(int x, int y, ScratchpadData data)) to build it pieces by pieces at runtime?

Or is there some existing way I missed? :p

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Tilemap, saving chunks for procedural generation.
« Reply #1 on: May 19, 2015, 11:39:44 pm »
Hi,

No its not possible to save the scratchpad, and there are no plans to do that. However you do have source, and the data for the scratchpads is stored in tk2dTileMapEditorData.scratchpads - you can write an editor script to copy and mirror this data into an asset / scriptable object in your project. You shouldn't need to modify any tk2d code to do this.

FZGames

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Tilemap, saving chunks for procedural generation.
« Reply #2 on: June 13, 2015, 03:52:08 pm »
Couldn't you just make a tilemap for each piece and save it as a prefab, then instantiate them together? I don't think there's any problem with lots of tilemaps together in one place. It'll use more colliders than it would with a single tilemap but I doubt it'd affect performance.