skip to Main Content

Scripting Support (C#)

The asset includes some useful public methods and properties to customize via scripting.

First, you need to get a reference to the CompassPro script, using:

using CompassNavigatorPro;
…
CompassPro compass = CompassPro.instance;

Once you have a reference to the compass instance, you can access its properties and methods. Example: compass.verticalPosition = 0.2f;

Properties

  • cameraMain: let you set the camera at runtime (useful if you change active camera).

  • follow: the object used to compute distances. Usually the character prefab or the cameraMain as well.
  • pois: the internal list that contains all POIs in the scene.
  • degrees: returns the current heading degrees of the compass.

  • style: choose between the available compass bar graphic styles.

  • visibleDistance: POIs beyond this distance won’t be visible in the compass bar.

  • nearDistance: distance threshold where the icons will start to grow.

  • visitedDistance: distance at which the POI is considered visited. The radius of the POI is also used with this property.

  • gizmoScale: scaling factor applied to in-scene icons.

  • alpha: the transparency of the compass bar.

  • autoHide: will hide the compass if no POIs are below visible distance. Compass will revert to visible when first POI gets nearer than visible distance.

  • fadeDuration: duration of the fade in/out effect.

  • verticalPosition: value (0 = bottom..1 = top) for the vertical position in the screen.

  • width: value (0..1, 1 = screen width) for the width of the compass bar.

  • endsCapWidth: size in pixels for the ending parts of the compass bar where you don’t want to show icons. This property must be set for each compass bar style.

  • minIconSize andmaxIconSize: scaling factors for the icons in the compass bar.

  • nearestPOI: returns the current nearest POI to the camera.
  • textVerticalPosition,textScale: controls the position and size of the text.

  • textRevealDuration,textRevealLetterDelay,textDuration, textFadeOutDuration: controls the animation cycle for the text (reveal, duration of the text on the screen, and finally duration for the fade out).

  • titleVerticalPosition,titleScale: controls the position and size of the POI’s title shown over the center of the compass bar.

  • showDistance: will show the distance in meters to the centered POI in the compass bar.

  • showCardinalPoints: will show N, W, S, E in the compass bar.

  • use3Ddistance: if enabled, the Y coordinate will be ignored when computing distance for icon scale. This property has no effect on the distance shown in the title (if showDistance is true).

  • sameAltitudeThreshold: the difference in altitude between the POI and the main camera to show “Above” or “Below” as part of the title.

  • visitedDefaultAudioClip: an optional audio clip to be played the first time a POI is visited. Note that you can specify a different audio clip in the POI script itself.

Mini-Map related properties

  • showMiniMap: shows/hides the mini-map.

  • miniMapZoomLevel: gets or sets the current mini-map zoom level (0-1) based on the min/max range defined in the Mini-Map properties.

  • miniMapFullScreenState: gets or sets the current mini-map zoom state (false = normal size, true = full-screen size)

  • miniMapFullScreenSize: the % of screen the mini-map fills when in full-screen mode. A value of 1 will make the mini-map fill the full screen.

  • miniMap*: public properties shown in the inspector are also accessible through scripting.

Methods

  • Refresh: forces a refresh of compass-bar and mini-map icons.

  • FadeIn(duration): shows the compass bar with a smooth fade in effect.

  • FadeOut(duration): hides the compass bar with a smooth fade out effect.

  • POIGetVisited(list): fills the list with all visited POIs in the scene.
  • POIGetUnvisited(list): fills the list with all non-visited POIs in the scene.
  • POIGetAll(list): fills the list with all existing POIs in the scene. You can also access the CompassPro.pois list directly.
  • POIFocus(CompassProPOI poi): makes a POI the principal POI. The icon will always be visible in the compass bar and a gizmo will be shown in the scene during playmode.

  • POIStartCircleAnimation(poi): triggers the start of the circle animation around a POI in the mini-map. 
  • POIBlur(): cancels POIFocus effect.

  • POIShowBeacon(CompassProPOI poi, duration, horizontalScale, intensity, color): activates a light beacon oriented to the sky which lights for a few seconds making easy to locate the distant POI in the scene from the player perspective.

  • POIShowBeacon(duration): activates a light beacon for all non-visited POIs oriented to the sky which lights for a few seconds making easy to locate the distant POIs in the scene from the player perspective.

  • ShowAnimatedText(text): triggers text appearing animation with a custom text.

  • MiniMapZoomIn / MiniMapZoomOut: zooms in/out the minimap with optional speed parameter.

  • UpdateFogOfWar(): resets and render the fog of war volumes in the mini-map.

  • ResetFogOfWar(alpha): fills entire scene with fog of war with given opacity.

  • SetFogOfWarAlpha (Vector3 worldPosition, float radius, float fogNewAlpha, float border)

Fills or clears an area around worldPosition. The radius is the distance in meters, fogNewAlpha specifies the value of transparency of the fog of war on this position (0-1) and border parameter specifies the smoothness of the edges (0-1).

  • SetFogOfWarAlpha (Bounds bounds, float fogNewAlpha, float border)

Same than previous method but updates within a given bounds.

  • SetFogOfWarAlpha (List<Vector3> points, float fogNewAlpha, float border)

Same than previous method but apply the fog of war along a path given by points. Can be used to simulate a route in the mini-map.

  • GetFogOfWar(Vector3 position).
    Returns the transparency or level of fog of war at a given position.

  • fogOfWarTextureData: gets or sets the contents of the internal fog of war texture. Can be used to persist fog of war state between sessions.

Events

  • OnPOIVisited: triggered when a POI is visited the first time (the POI is passed as parameter).

  • OnPOIVisible: triggered when a POI gets near than the visible distance (and appears in the compass bar).

  • OnPOIHide: triggered when a POI gets farther than the visible distance (and disappears in the compass bar).

  • OnHeartbeat: this event is triggered by the individual POI (it’s defined in CompassProPOI class and not in CompassPro). Triggered when the POI plays a heartbeat sound.

  • OnPOIVisibleInMiniMap: triggered when a POI appears in the mini-map.

  • OnPOIMiniMapIconMouseEnter: triggered when mouse enters an icon in the mini-map (as it enters the icon rectangle).

  • OnPOIMiniMapIconMouseExit: triggered when mouse exits an icon in the mini-map.

  • OnPOIMiniMapIconMouseDown: triggered when mouse button is pressed on an icon in the mini-map.

  • OnPOIMiniMapIconMouseUp: triggered when mouse button is released from an icon in the mini-map.

  • OnPOIMiniMapIconMouseClick: triggered when mouse button clicks on an icon in the mini-map.

  • OnMiniMapChangeFullScreenState: triggered when mini-map full screen mode is changed.

  • OnMiniMapMouseEnter / OnMiniMapMouseExit: triggered when mouse enters/exits the area of the mini-map on screen.
  • OnMiniMapMouseClick: triggered when user clicks with mouse on the mini-map (the event handler gets the world position where user clicks, check demo scene for an example).

Generic events

OnPOIRegister: Event fired when a POI is added to the compass system
OnPOIUnregister: Event fired when a POI is removed from the compass system
OnPOIVisited: Event fired when this POI is visited for the first time
OnPOIEnterCircle: Event fired when player enters the circle/radius of a POI
OnPOIExitCircle: Event fired when a player exits the circle of a PO

Compass events

OnPOIVisible: Event fired when the POI appears in the compass bar (gets near than the visible distance)
OnPOIHide: Event fired when POI disappears from the compass bar (gets farther than the visible distance)

Mini-map events

OnPOIMiniMapIconMouseEnter: Event fired when mouse enters an icon on the miniMap
OnPOIMiniMapIconMouseExit: Event fired when mouse exits an icon on the miniMap
OnPOIMiniMapIconMouseDown: Event fired when button is pressed on an icon on the miniMap
OnPOIMiniMapIconMouseUp: Event fired when button is released on an icon on the miniMap
OnPOIMiniMapIconMouseClick: Event fired when an icon is clicked on the minimap
OnPOIVisibleInMiniMap: Event fired when this POI appears in the Mini-Map
nPOIHidesInMiniMap: Event fired when the POI disappears from the Mini-Map
OnMiniMapChangeFullScreenState: Event fired when full screen mode changes
OnMiniMapMouseClick: Event fired when user clicks on minimap - sends the world space position of click
OnMiniMapMouseEnter: Event fired when mouse enters minimap area in the screen
OnMiniMapMouseExit: Event fired when mouse exits minimap area in the screen

Indicators events

OnPOIOnScreen: Event fired when the indicator of this POI appears on screen
OnPOIOffScreen: Event fired when the indicator of this POI goes off-screen
Back To Top