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.
In the first part of this series I will explain 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 two will explain 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.
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.
Part four 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.
-----
Get the Tiles Asset here:
My Singleton File:
EngiGames Tutorial to Singletons (his script is linked in his description):
=========
💻 CODE:
💬 DISCORD:
❤ SUPPORT ME:
🎮 PLAY MY GAMES:
🦜 TWITTER:
💡 ...MORE TUTORIALS:
=========
Timestamps:
00:00 - Intro
00:37 - Import Assets & Prepare Tiles
01:45 - ScriptableObjects: Create the BuildingObjects
03:39 - Add the Items as “ScriptedObjects“
05:34 - Setup the Building UI
08:04 - Implement the Button Functionality
10:05 - Let me know the content you want to see :)
10:34 - Installing the New Input System & Preparing the Input Action
12:20 - Update Your Event System!
12:35 - Let’s use a Singleton
13:10 - Code the BuildingCreator script - Create the Preview
19:30 - Testing the Preview
20:40 - DRAW the Tile - Implement the Click Handling
22:43 - Testing the Functionality
22:55 - Change the “Order in Layer“ of the PreviewMap
23:13 - Thank you for watching :)