How to save Unity Tilemaps

  Рет қаралды 15,708

Tarodev

Tarodev

Күн бұрын

Learn how to load and save Unity tilemaps using scriptable objects.
Alternatively, I'll show you how to convert tilemaps into JSON or a compressed string so that you can easily save them to a database and allow players to create their own levels to share.
Extra: Learn how to add buttons to your unity editor scripts.
Scripts: bit.ly/3wLN8Sk
=========
SUBSCRIBE: bit.ly/3eqG1Z6
0:00 Intro
0:30 Base tile script
2:30 Tilemap Manager
3:45 Create the level scriptable object
5:00 Saving the map
11:00 Adding buttons to the editor
14:00 Clearing the map
15:45 Loading the map
21:00 Saving to JSON
22:40 Manual serialization for compression

Пікірлер: 47
@olon1993
@olon1993 2 жыл бұрын
Why I ❤this channel: Came here to learn about Tilemaps Encountered local functions for the first time Learned about both. Better game dev Better software dev 20/10, video did the job of two videos
@barriakarl
@barriakarl Жыл бұрын
Just perfect tutorial. Was a bit scared you wouldnt show how to save to json there but glad you decided to.
@lollipop.4784
@lollipop.4784 2 жыл бұрын
Dude, you are so underrated!!! Thank you so much for the video and you have helped me a lot! keep up the good work
@charles_richard
@charles_richard 9 ай бұрын
Thank you so, so much! This video has helped me immensely. It should have 10x more views, man!
@minetomek
@minetomek Жыл бұрын
Amazing vidoe. Helped me a lot!
@user-zb9lo4sl9h
@user-zb9lo4sl9h 3 жыл бұрын
Cool, thanks so much for your time and consideration
@AwataraGame
@AwataraGame Жыл бұрын
Hi @Tarodev it's very very useful tutorial, I have modified your tutorial into very efficient with combine between Scriptable Objects and Tile, so I can call the tiles after I quit the game, Thanks for the tutorials!
@MalrickEQ2
@MalrickEQ2 Жыл бұрын
Exactly what I needed! Thanks!!
@Tarodev
@Tarodev Жыл бұрын
You're welcome ❤️
@user-ke5jx7hb9e
@user-ke5jx7hb9e 2 жыл бұрын
Thanks for the video!
@orick08
@orick08 2 жыл бұрын
Nice, when I finish the videos of the tactics games I search for how to do exactly this!!!
@vamporium432
@vamporium432 2 жыл бұрын
You didn't tackle the Deserialize() part of the Level struct. Would you do it with string.Split() or string.IndexOf or similar string manipulation? Or do you have another (maybe more efficient) approach?
@LethalChicken77
@LethalChicken77 Жыл бұрын
In my implementation I used string.split, and used commas and brackets as seperators
@Elite_Success
@Elite_Success 9 ай бұрын
Hey man can you please share the code? I couldn't figure out how to doit@@LethalChicken77
@moneodev
@moneodev 10 ай бұрын
Really nice tutorial! The only thing that was really missing was how to unserialize the .txt file but good overall!
@Elite_Success
@Elite_Success 9 ай бұрын
Love the video man! However I couldn't figure out how to deserialize the more optimized way you showed at the end. Can you please help with that?
@ironbard4901
@ironbard4901 2 жыл бұрын
Subscribers++; I'm crunching on a game and this might just save some features from the chopping block. Thank you!
@MalrickEQ2
@MalrickEQ2 Жыл бұрын
Also, Inspector GUI sounds like a show on BBC.
@noobcraft5712
@noobcraft5712 3 жыл бұрын
Cool :)
@bienphamxuan3295
@bienphamxuan3295 Жыл бұрын
That's so good. But I'm facing a problem when I using a multiple tiles in tile palette, not just use one tiles to save like this video. Could you give me some advice to do this.
@atrejoprivate9541
@atrejoprivate9541 2 жыл бұрын
thanks for helpng me
@Tarodev
@Tarodev 2 жыл бұрын
Glad it helped you 😊
@322ss
@322ss 2 жыл бұрын
Thanks for the video, some interesting points there. BTW, it would not probably be a good idea to ever serialize those scriptable objects into json as is, those tile instance IDs can change AFAIK. So after adding or removing some stuff from project and then loading a level might not work as expected, even if the save/load was editor only feature. I guess you already know this, but there is that pretty print parameter for JSONUtility which outputs the data with line breaks and indentations, it is pretty useful when you need to read that data in text editor.
@Tarodev
@Tarodev 2 жыл бұрын
You're right, you should never serialize a ScriptableObject. It was naughty of me to use it as an example. Hopefully viewers don't stop the video right there and take it to heart without listening to the following advice, heh.
@MetaKnight23
@MetaKnight23 2 жыл бұрын
is there a good solution if I have a mix of RuleTiles, AnimatedTiles and normal Tiles? do I have to create individuell "LevelTiles" and save them in different Lists ?
@michaelconnell3497
@michaelconnell3497 2 жыл бұрын
Yeah, I created a LevelRuleTile and gave it its own tilemap. Only minor changes to the code were necessary.
@LethalChicken77
@LethalChicken77 Жыл бұрын
My personal favorite solution to this is to simply not. Unfortunately sometimes it is required.
@user-by3ov4bh6p
@user-by3ov4bh6p Жыл бұрын
I need level editor ingame, with tilemaps and layers😥
@midniteoilsoftware
@midniteoilsoftware 2 жыл бұрын
I humbly request you zoom into your code editor :)
@Tarodev
@Tarodev 2 жыл бұрын
I do in new videos 😊 I've learned!
@diego_4812
@diego_4812 Жыл бұрын
Hi, I use this save and load system to load/unload chunks in my tilemap, it works but, when i load a chunk this have a little lag :( , i try changing the max tile change count from my tilemap collider 2d to a lower number but, this only made it slightly better Can you think of any way to fix that?
@andreman2767
@andreman2767 Жыл бұрын
It should be async save and load (dont really into it)
@diego_4812
@diego_4812 Жыл бұрын
The problem was that the collider 2d mesh didn't have a simple geometry and that's why it took so long to load and save, currently this system works perfectly for me :)
@cookiemonster_xx
@cookiemonster_xx 2 жыл бұрын
Is it possible to use this script with rule tiles? When I try to safe a rule tile to my level the "Tile" field stays empty
@Tarodev
@Tarodev 2 жыл бұрын
Don't try to serialize the entire rule tile, save the tile type and position. When you load you check that it's a rule tile and lay it down
@skytrymotion
@skytrymotion 2 жыл бұрын
@@Tarodev Could you explain it a bit, I have no Idea what I should do
@vomgame
@vomgame 2 жыл бұрын
Пригодится
@Tarodev
@Tarodev 2 жыл бұрын
Making me google translate :P
@ukidabek
@ukidabek 2 жыл бұрын
Enums don't have to have Serializable attribute. :)
@Tarodev
@Tarodev 2 жыл бұрын
Indeed. I serialize them to see them in the inspector (I don't remember if I used them in the inspector in this video)
@themrfj
@themrfj Жыл бұрын
Why don't you just create the scriptableobject at the start, then add and remove SavedTile objects as you place them at runtime? No need to look through the tilemap :)
@themrfj
@themrfj Жыл бұрын
That is NOT the use of the word save I though you were going for :P I thought you were "saving" the tilemap feature from being bad :)
@Tarodev
@Tarodev Жыл бұрын
I am only human 😂
@themrfj
@themrfj Жыл бұрын
Ha ha :D In all seriousness, it's not as bad as I first thought. I think I'm finally getting the hang of it. Took a few months though!
@Korn1holio
@Korn1holio Жыл бұрын
Damn. That's why I kinda hate Unity. Such a commonly needed functionality have to be coded using all sorts of crutches...
@Tarodev
@Tarodev Жыл бұрын
Like serializing and saving tile maps? Yeah... I agree things like this should be native
@light-light
@light-light Жыл бұрын
Why unity does not provide this basic function?
Explosions in Unity! Let's blow some stuff up ;)
6:00
Tarodev
Рет қаралды 40 М.
Rethink Everything with Scriptable Object VARIABLES
15:28
Increíble final 😱
00:37
Juan De Dios Pantoja 2
Рет қаралды 107 МЛН
ОДИН ДЕНЬ ИЗ ДЕТСТВА❤️ #shorts
00:59
BATEK_OFFICIAL
Рет қаралды 7 МЛН
Haha😂 Power💪 #trending #funny #viral #shorts
00:18
Reaction Station TV
Рет қаралды 14 МЛН
Мы никогда не были так напуганы!
00:15
Аришнев
Рет қаралды 3,3 МЛН
Object Pooling in Unity 2021 is Dope AF
18:10
Tarodev
Рет қаралды 118 М.
Games Where You're NOT the Main Character
14:52
i am a dot.
Рет қаралды 1,7 МЛН
10 Things You NEED to Be Doing in Unity
11:40
Tarodev
Рет қаралды 126 М.
Ability Bar in Unity (Swap Weapons/Items)
29:07
Code Monkey
Рет қаралды 31 М.
Unity 2021 Use Scriptable Object instead of Enum
10:57
Sunny Valley Studio
Рет қаралды 36 М.
Be CAREFUL with Scriptable Objects!
8:27
Code Monkey
Рет қаралды 75 М.
Increíble final 😱
00:37
Juan De Dios Pantoja 2
Рет қаралды 107 МЛН