InteractWithObject.cs - MitchOSully/Visualising-the-DFN-Dataset GitHub Wiki

Summary

If this script is added to a GameObject, you can do three things:

  1. Hover over object to see its name
  2. Click on object to display a window with information about that object
  3. Double-click on object to make it the center of the camera

List of Functions

Public Global Variables
Private Global Variables

void OnMouseEnter()
void OnMouseExit()
void OnMouseUpAsButton()
void OnMouseOver()
float getDistance()

Public Global Variables

ScreenMaster screenScript

Reference to ScreenMaster.cs for displaying the information panel and changing the pivot in the drop-down menu.

GameObject nameDisplayPrefab

Used to instantiate nameDisplay.

float labelSize

The local scale of the label. Default value is 1.

Private Global Variables

GameObject nameDisplay

The mini canvas (GUI object) that is displayed over the planet or meteoroid when the cursor hovers over it.

void OnMouseEnter()

Displays a label above the GameObject that this script is attached to. The text in the label is the name of the GameObject. The size of the label is dependent on the distance from the camera.

Params

None

Returns

None

Calls

Called By

  • When the cursor is hovered over the GameObject.

void OnMouseExit()

Deletes the label.

Params

None

Returns

None

Calls

None

Called By

  • When the cursor stops hovering over the GameObject.

void OnMouseUpAsButton()

Accesses the drop-down menu on the screen and changes its value to this GameObject. The drop-down menu changes the pivot for us.

Params

None

Returns

None

Calls

None

Called By

  • When the user clicks on the GameObject.

void OnMouseOver()

Checks if there's a right-click; if so, displays the panel of information on the screen. Only does this if clickingActive is true.

Params

None

Returns

None

Calls

Called By

  • Repeatedly called every frame as long as the cursor is hovers over the GameObject.

float getDistance()

Calculates the distance between the camera and this GameObject.

Params

None

Returns

Name Type Description
distance float The distance between camera and the GameObject that this script is attached to.

Calls

None

Called By