The reticle cursor
A variant of the visor HUD that is essential in first-person shooter games is a reticle or crosshair cursor. The analogy here is that you're looking through a gun-sight or an eyepiece (rather than a visor) and your head movement is moving in unison with the gun or turret itself. You can do this with a regular game object (for example, Quad + texture image), but this chapter is about UI. So, let's use our canvas, as follows:
- Find your
Main Camera
object in theHierarchy
panel as we did previously. - From the
Project
panel, drag theDefaultCanvas
prefab onto the camera object so that it becomes a child of the camera. Name itReticleCursor
. - Set the
Rect Transform
component'sPos X
,Pos Y
,Pos Z
to (0
,0
,1
). - Delete its child objects:
Image
andText
. This will break the prefab association; that's OK. - Add a raw image child by selecting it from the main menu bar, navigating through
GameObject
|UI
|Raw Image
and making sure that it's a child ofReticleCursor
. - In the
Raw Image
panel...