SOVEREIGN MOON PRESENTS…
How to Add Dialogue Boxes & Text Info Popups in Unity’s 3D Game Kit
In this tutorial we’ll learn how to add dialogue boxes using the “info zone” prefab within Unity’s 3D Game Kit.
Sovereign Moon Studios is dedicated to helping game enthusiasts bring their creative visions to life by teaching them how to make a video game from scratch without having to know how to code or draw.
How to add Dialogue Text Boxes Within Uniy’s 3D Game Kit
Today, Sovereign Moon Studios, the makers of your favorite NoCode game development course, are excited to bring you a new tutorial that will walk you through the steps required to add dialogue boxes and text popups into your Unity 3D Game Kit video game.
Let’s jump in!
Being able to add dialogue boxes into your Unity game using the free 3D Game Kit add-on is easy and doesn’t require any coding.
Let me walk you through the steps of adding dialogue boxes
Step 1: Add an “Info Zone”
Let’s begin by adding something into our scene that will act as a visual cue for our character to interact with. This object can be anything, but in our example, we’re going to use a crystal as our main object. When our character approaches the crystal a text box will popup with information for the character.
To add an info zone, we simply need to look under our “interactibles” folder (under our “prefabs” folder) and look for the item called “info zone”. We then need to drag and drop the info zone component under our “game utilities” section within our scene hierarchy tab.
Once we have that done, we need to scale the info zone object down so that it only covers the area we want to use as our trigger area. Because we’re using a small crystal in this example, we’re going to scale down our info zone collider until it reaches out just past the limits of our crystal. This will mean that our character will need to walk close to the object before the dialogue box will popup.
Step 2: Add Dialogue UI Prefab
Essentially, the info zone acts as our trigger area. this is the area within 3D space that our player will need to walk inside of in order to have the text boxes popup.
Next, we need to look under our prefabs folder for the sub folder UI prefabs. Within the UI prefabs folder, you’ll see an object called DialogueCanvas.Prefab. Drag and drop this object into the UI section of your hierarchy window.
Step 3: Connecting the Dialogue Controller to the Info Box
All we have left to do is connect the dialogue controller prefab to our info box. To do this, we first need to select the Info Box from our hierarchy section. Once selected, the object’s details will show up under our inspector tab. You will notice there is an “interact on trigger (script)” component within the inspector tab. Within this area, we’ll need to make a few edits to tell Unity and 3D Game Kit what we want the info box to do when the player enters and exits this region.
Of course, we want Unity to display a popup text box when the player enters this region and we want the popup box to disappear once the player has left the region.
So let’s set these up now.
First, ensure “layers” is set to “player”.
Next, under “on enter” we need to drag and drop our dialogue controller (from our hierarchy section) into the object section (as outlined in the video above). Once this is done we need to change the function to “DialogueCanvasController” and then we need to select “ActivateCanvasWithText (string)“. Once you do that, a small text area will be visible where you can enter the text you want to display once this object is selected.
Step 4: Setting Up “On Exit”
The last thing we need to setup is what we want our game to do once our player exits the info zone. In order to do this, we simply to to select “DialogueCanvasController” and then “DeactivateCanvasWithDelay (float)”. Because this function uses “float” and not “string”, we need to insert a number which will tell Unity how long we want the message to stay up on the screen after the character has left the info box area. In our example, we’ll set this to 2 which will represent 2 seconds.
Once we have completed that step, we can play our game and test out our dialogue box.
My goal today was to show you how to add a dialogue box using what you already have at your disposal within Unity’s 3D Game Kit. However, there are many other ways to add a dialogue system into your Unity game as well. For example, you could use Bolt, Unity’s free visual scripting add-on to do the same thing. However, my goal today was to keep the creation of a dialogue system as simple as possible.
So that’s all I have for you today. Thanks for stopping by our blog. In the next tutorial in this series I’ll teach you how to use switches and counters within your game worlds to create more interesting game mechanics.
If you are an indie game maker and you’re looking to bring your no-code game development skills to the next level, then consider signing up for our comprehensive no-code game development course. In that course, we’ll dive into much more detail and help you make breathtaking indie video games without having to know how to code, how to draw or how to animate. Simply visit our homepage to learn more.
Sovereign Moon Studios is dedicated to helping game enthusiasts bring their creative visions to life without having to know how to code or draw. Our NoCode game development course teaches indie game devs how to build breathtaking games from scratch.
Want to Make Video Games?
Do you love game design? So do we! For this reason, we created a no-code video game development course that walks you through the process of bringing your game visions to life without needing to know how to program and without having to be an artist. We will teach you how to bring your game to life in our 4 hour 36 module no-code game development course.