Exercise - Provide description to objects using text on scene and tooltips
Adding text to a scene can be very informative and can guide the users. Here you'll add text to the scene using TextMesh Pro and include Tooltips to provide short descriptions for each object.
Add text to the scene
In the Hierarchy pane , right-click the Table object and select 3D Object > Text - TextMeshPro to add a text object as a child of the Table object, and then in the Inspector pane, configure the Rect Transform component as follows:
- Change Pos Y to 1
- Change Width to 1
- Change Height to 1
- Change Rotation X to 90
Configure the TextMeshPro - Text component as follows:
- Change Text to Rover Explorer
- Change Font Style to Bold
- Change Font Size to 1
- Change Extra Settings > Margins to 0.03
Add tooltips
In the Project pane, navigate to Packages > Mixed Reality Toolkit Foundation > SDK > Features > UX > Prefabs > ToolTip folder to locate the tooltip prefabs:
In the Hierarchy pane, expand the RoverExplorer > RoverParts object and select all its child rover part objects, and then in the Inspector pane, select Add Component to add the ToolTipSpawner component and configure it as follows:
- Ensure the Focus Enabled checkbox is checked to require the user to look at the part for the tooltip to appear
- Assign the Simple Line ToolTip prefab from the Project window to the Prefab field
- Change the ToolTip Override Settings > Settings Mode to Override
- Change the ToolTip Override Settings > Manual Pivot Local Position Y to 1.5
In the Hierarchy pane, select the first rover part, RoverParts > Camera_Part, and configure the ToolTipSpawner component as follows:
- Change Tool Tip Text to reflect the name of the part, that is, Camera
Repeat this step for each of the rover part objects to configure the ToolTipSpawner component as follows:
- For the Generator_Part, change the Tool Tip Text to Generator
- For the Lights_Part, change the Tool Tip Text to Lights
- For the UHFAntenna_Part, change the Tool Tip Text to UHF Antenna field
- For the Spectrometer_Part, change the Tool Tip Text to Spectrometer
Press Play to enter Game mode, and then press-and-hold the right mouse button while moving your mouse until the gaze hits one of the parts and the tooltip for that part displays:
Trebate pomoć? Pogledajte naš vodič za rješavanje problema ili pošaljite željene povratne informacije prijavljivanjem problema.