InGame Tilemap Editing - Part 7: The Build History - Undo & Redo Steps - Unity Tutorial
ฝัง
- เผยแพร่เมื่อ 16 ธ.ค. 2024
- In this episode we will create an option for keeping a build history in memory. With an undo and a redo function we will be able to iterate through this history. There will also be part 7.2 soon. Feel free to check out the complete source code in the according GitHub repo.
The singleton explanation from episode 1: • InGame Tilemap Editing...
ABOUT THIS SERIES:
In this tutorial series you will learn how you can create an ingame UI where your players can draw on a grid. We are going to use Unitys Tilemaps and there will be a lot of coding involved. You'll learn how you can add the UI with clickable buttons, how to show a preview where an item would be placed and of course you can place it. It will then be drawn onto a tilemap.
Part 1: I explained the basic setup and by the end you can place items with a simple click. We will also use Unitys New Input System for the input handling. The UI will be created by hand but automated in another part of the series.
Part 2: will explained how you can create rectangles and lines via click and hold events, also done with the new Input System. We will assign those drawing styles to the categories the items belongs to, so that for example a wall will be always drawable as a line.
Part 3: To combine items like a floor and a vase on top you need several tilemaps. In part three of the series we expand the code to support different tilemaps for different categories we draw. The tilemaps will be generated during game start and therefore help you with easy maintainability. I will group the tilemap creation by category, so for every category it is possible to create an own tilemap. This can be adjusted as you wish by just usign the tutorial as an foundation.
Part 4: shows you how to automate the UI. With a little bit more code and configuration your drawing buttons will spawn on game start. So you can easily expand the drawable objects without the need to add more annoying UI things.
Part 5: Deleting tiles with a "Tooling Feature" which will handle custom code for different use cases.
Part 6: You will learn methods how to restrict tile placement based on different criteria like environment or placed tiles on other tilemaps. This will prevent e.g. placement inside water or also placing e.g. walls on top of items.
Part 7: We will create an option for keeping a build history in memory. With an undo and a redo function we will be able to iterate through this history.
=========
Spoiler-Warning: The GitHub repo already contains the full code for this + the upcoming episode continuing this topic.
💻 CODE: github.com/Mic...
💬 DISCORD: / discord
❤ SUPPORT ME: / velvary
🎮 PLAY MY GAMES: velvary.itch.io/
🦜 TWITTER: / velvary1
💡 ...MORE TUTORIALS: / velvarygames
=========
Timestamps:
00:00 - Intro
00:52 - The UI Buttons
01:31 - Creating the Button Handler
02:11 - The BuildingHistory Script
05:52 - Update the BuildingHistoryHandler
06:12 - Fill the History List
07:08 - Testing the Functionality
07:57 - Thank you for watching :)