3.9. C# UI.Hints

3.9.1. UiInputHints.cs

class UI.Hints.UiInputHints : public MonoBehaviour

Defines the behaviour of the input hints of one hand. Important functions are: AddTooltip(GameObject, string), SetData and Repaint.

In short, tooltips can be added so when we hover over a UI element it displays some text. Repaint is called with the collection to set out the default hints for a particular state. This can then be overriden by scripting, e.g. see RepaintTriggerColor where we set the trigger hint color ot the active selection color.

Public Functions

void Initialize ()
void SetData (UiInputHintsData data)

Set the data that should be displayed. Note: Consider the overrides and the ordering when calling this multiple times.

void Repaint ()

Refreshes the Input hints based on the InputState.ActiveTool and the sub state like ToolTransformMode

Public Members

UiInputLabel title
UiInputLabel help
UiInputLabel trigger
UiInputLabel grip
UiInputLabel primaryBtn
UiInputLabel secondaryBtn
UiInputLabel primaryAxisX
UiInputLabel primaryAxisY

Public Static Functions

void AddTooltip (GameObject uiElement, string msg)

Display the message when hovering over this UI element. Note: Must be attached to the gameObject with the button/toggle component, otherwise clicking may be blocked

Parameters
  • uiElement: GameObject with the Button/Toggle UI component

  • msg: Message to display when hovering

void AddTooltip (GameObject uiElement, Func<string> msg)

An overload where the message can be a lambda.

Private Functions

void SetTooltip (string data, bool overrideExisting = false)

Apply text to the help/tooltip. Used by the UI.

void ClearTooltip ()
void RepaintTriggerColor ()

Sets the trigger hint background color based on the active selection for the active mesh. Implementation note: Example of input hints driven by scripting. We ensure with the events On*Changed that this function is called only when the ActiveMesh changes or the selection of the ActiveMesh.

void OnActiveMeshChanged ()
void OnDestroy ()

Private Members

UiInputHintsDataCollection collection = null
UiInputHintsData _currentData
LibiglBehaviour _activeBehaviour
const float DefaultTooltipTimeout = 60f

3.9.2. UiInputLabel.cs

class UI.Hints.UiInputLabel : public MonoBehaviour

A label for a physical input button/axis to give a hint to what it does.

Public Functions

void Initialize ()
void SetData (UiInputLabelData data, bool overwriteData = true)
void SetText (string data)
void SetColor (Color value)
void SetIcon (Sprite sprite)
void ResetToData ()

Resets the label to the last written data, set when SetData overwriteData = true.

Public Members

Image background
Image icon
TMP_Text text

Private Members

UiInputLabelData _data
Color _defaultColor = Color.white

3.9.3. Data

3.9.3.1. UiInputHintsDataCollection.cs

class UI.Hints.UiInputHintsDataCollection : public ScriptableObject

Stores the hints for all possible states of the ActiveTool and sub-states. These are stored as a hierarchy. UiInputHints.Repaint defines how this data is applied. There will be one instance for the left and one for the right hand.

Public Members

UiInputHintsData defaultHints
UiInputHintsData transform
UiInputHintsData transformIdle
UiInputHintsData transformTransformingL
UiInputHintsData transformTransformingR
UiInputHintsData transformTransformingLr
UiInputHintsData select
UiInputHintsData selectIdle
UiInputHintsData selectSelecting
UiInputHintsData selectTransformL
UiInputHintsData selectTransformR
UiInputHintsData selectTransformLr

3.9.3.2. UiInputHintsData.cs

class UI.Hints.UiInputHintsData : public ScriptableObject

Data for one hand and one state of the ActiveTool. Used by the UiInputHints. We have one UiInputLabelData per button/axis.

Public Members

UiInputLabelData title
UiInputLabelData help
UiInputLabelData trigger
UiInputLabelData grip
UiInputLabelData primaryBtn
UiInputLabelData secondaryBtn
UiInputLabelData primaryAxisX
UiInputLabelData primaryAxisY

3.9.3.3. UiInputLabelData.cs

struct UI.Hints.UiInputLabelData

Defines the content for a UiInputLabel.

Public Members

bool isOverride
bool isActive
Sprite icon
string text