The info bubble
In a comic book, when a character says something, it's shown in a speech bubble. In many online social worlds, participants are represented by avatars and if you hover above someone's avatar, their name is displayed. I'll call this type of user interface an info bubble.
Info bubbles are located in world space at a specific 3D position, but the canvas should always be facing the camera. We can ensure this with a script.
In this example, we'll display the X, Z location of the WalkTarget
object (set up in the previous chapter), controlled by the LookMoveTo.cs
script. To add the info bubble, perform the following steps:
From the Project panel, drag the
DefaultCanvas
prefab directly into the Scene view on top ofWalkTarget
underGameController
so that its a child ofWalkTarget
.Rename it to
InfoBubble
.With
InfoBubble
selected, set the Rect Transform component's Pos X, Pos Y, Pos Z to (0
,0.2
,0
).With Text under
InfoBubble
selected, set the Rect Transform component's Pos X, Pos Y,...