Scripting Support (C#)
advanced scriptingCompass Navigator Pro 3 · Scripting Support (C#)
CompassNavigatorPro component (namespace CompassNavigatorPro). Access via CompassPro.instance.
CompassPro.instance. POIs are self-registering MonoBehavior components — add CompassProPOI to any game object.
Getting Started
Add the namespace and access the compass singleton:
using CompassNavigatorPro;
CompassPro compass = CompassPro.instance;
Compass Bar
bool showCompassBar { get; set; }Show or hide the compass bar.
CompassStyle style { get; set; }Visual style of the compass bar (Angled, Rounded, Celtic, Fantasy, SciFi, Clean variants, or Custom).
Transform follow { get; set; }The transform the compass follows (usually the player).
float alpha { get; set; }Compass bar transparency (0–1).
float width { get; set; }Bar width as percentage of screen.
float verticalPosition { get; set; }Vertical screen position (0–1, from bottom).
float degrees { get; }Current compass orientation in degrees (read-only).
float northDegrees { get; set; }North position offset in degrees.
float visibleMaxDistance { get; set; }Maximum distance for POI visibility on the compass bar.
float visitedDistance { get; set; }Distance at which a POI is considered "visited".
POI Management
bool POIRegister(CompassProPOI newPOI)Registers a POI with the compass system. POIs auto-register on Start, but call this if adding dynamically.
void POIUnregister(CompassProPOI newPOI)Removes a POI from the compass.
bool POIisRegistered(CompassProPOI poi)Checks if a POI is currently registered.
void POIFocus(CompassProPOI poi)Makes a POI always visible on the compass bar.
void POIBlur()Removes focus from the currently focused POI.
void POISetVisited(CompassProPOI poi, bool visited)Marks a POI as visited or unvisited.
void POIGetAll(List<CompassProPOI> pois)Fills a list with all registered POIs.
void POIGetVisited(List<CompassProPOI> pois)Fills a list with all visited POIs.
void POIGetUnvisited(List<CompassProPOI> pois)Fills a list with all unvisited POIs.
CompassProPOI nearestPOI { get; }Reference to the nearest registered POI (read-only).
CompassProPOI focusedPOI { get; set; }The POI that is always visible on the compass bar.
CompassProPOI Component
Add this component to any game object to make it a Point of Interest.
string titlePOI name displayed on the compass bar.
bool isVisited { get; set; }Whether this POI has been visited.
Sprite iconNonVisitedIcon displayed when the POI hasn't been visited yet.
Sprite iconVisitedIcon displayed after the POI has been visited.
Color tintColorIcon tint color.
float radiusArea of interest radius around the POI.
POIVisibility visibilityVisibility mode: WhenInRange, AlwaysVisible, or AlwaysHidden.
bool clampPositionClamp icon to compass bar edges when out of range.
bool showOnScreenIndicatorShow an in-world indicator pointing to this POI.
bool showOffScreenIndicatorShow edge-of-screen arrows when the POI is off screen.
bool hideWhenVisitedRemove from the UI after being visited.
string visitedTextDiscovery text shown when the POI is visited.
OnHeartbeatEvent OnHeartbeat()Delegate called each time the heartbeat effect plays a sound for this POI. Assign a callback to react to heartbeat pulses as the player approaches.
Mini-Map
bool showMiniMap { get; set; }Show or hide the mini-map.
MiniMapStyle miniMapStyle { get; set; }Border style: TornPaper, SolidBox, SolidCircle, Fantasy, SciFi, Custom, or None.
MiniMapPosition miniMapLocation { get; set; }Screen corner: TopLeft, TopCenter, TopRight, MiddleLeft, etc.
float miniMapSize { get; set; }Mini-map size as percentage of screen height.
float miniMapZoomLevel { get; set; }Current zoom level (0–1).
MiniMapContents miniMapContents { get; set; }Display mode: TopDownWorldView, WorldMappedTexture, UITexture, or Radar.
bool miniMapFullScreenState { get; set; }Get or set full-screen mini-map mode.
bool miniMapKeepStraight { get; set; }Keep mini-map oriented to North.
float miniMapCaptureSize { get; set; }Camera orthographic size for world capture.
LayerMask miniMapLayerMask { get; set; }Layers visible in the mini-map.
void MiniMapZoomIn(float speed = 1f)Zooms the mini-map in.
void MiniMapZoomOut(float speed = 1f)Zooms the mini-map out.
void UpdateMiniMapContents(int numberOfFramesToRefresh = 1)Forces a mini-map content refresh.
bool IsMouseOverMiniMap()Returns true if the mouse cursor is over the mini-map.
Fog of War
bool fogOfWarEnabled { get; set; }Enable the fog of war system.
Vector3 fogOfWarCenter { get; set; }Center position of the fog of war area.
Vector3 fogOfWarSize { get; set; }Size of the fog of war area.
bool fogOfWarAutoClear { get; set; }Automatically clear fog as the player moves.
float fogOfWarAutoClearRadius { get; set; }Radius of automatic fog clearing around the player.
void SetFogOfWarAlpha(Vector3 worldPosition, float radius, float fogNewAlpha, float border)Sets fog alpha in a circular area. Use 0 to reveal, 1 to hide.
void SetFogOfWarAlpha(Bounds bounds, float fogNewAlpha, float border)Sets fog alpha within a rectangular bounds area.
float GetFogOfWarAlpha(Vector3 worldPosition)Returns the current fog alpha at a position.
void ResetFogOfWar(float alpha = 1f)Resets the entire fog of war area.
Color32[] fogOfWarTextureData { get; set; }Direct access to fog of war pixel data for save/load.
Beacons & Effects
GameObject POIShowBeacon(CompassProPOI poi, float duration, float horizontalScale = 1f)Shows a beacon effect on a POI for the specified duration.
GameObject POIShowBeacon(Vector3 position, float duration)Shows a beacon effect at a world position.
void ShowAnimatedText(string text)Displays animated discovery text on the compass bar.
void FadeIn(float duration)Fades the compass bar in.
void FadeOut(float duration)Fades the compass bar out.
Scan System
ScanEffect Scan()Performs a radar-like scan effect from the player position.
ScanEffect Scan(ScanProfile profile)Performs a scan using a custom ScanProfile asset.
Events
UnityEvent<CompassProPOI> OnPOIVisited(CompassProPOI poi)Fired when a POI is visited.
UnityEvent<CompassProPOI> OnPOIVisible(CompassProPOI poi)Fired when a POI appears on the compass bar.
UnityEvent<CompassProPOI> OnPOIHide(CompassProPOI poi)Fired when a POI disappears from the compass bar.
UnityEvent<CompassProPOI, GameObject> OnCompassBarIconCreated(CompassProPOI poi, GameObject iconGO)Fired when a compass bar icon is created for a POI. Use this to customize the icon GameObject after creation.
UnityEvent<CompassProPOI> OnPOIRegister(CompassProPOI poi)Fired when a POI is registered.
UnityEvent<CompassProPOI> OnPOIUnregister(CompassProPOI poi)Fired when a POI is removed from the compass system.
UnityEvent<CompassProPOI> OnPOIEnterCircle(CompassProPOI poi)Fired when the player enters a POI's radius.
UnityEvent<CompassProPOI> OnPOIExitCircle(CompassProPOI poi)Fired when the player exits a POI's radius.
UnityEvent<CompassProPOI> UnityEvent<CompassProPOI, GameObject> OnIndicatorCreated(CompassProPOI poi, GameObject indicatorGO)Fired when an on-screen indicator is created for a POI. Use this to customize the indicator GameObject after creation.
UnityEvent<CompassProPOI> OnPOIOnScreen(CompassProPOI poi)Fired when the on-screen indicator for a POI appears.
UnityEvent<CompassProPOI> OnPOIOffScreen(CompassProPOI poi)Fired when the on-screen indicator for a POI goes off-screen.
UnityEvent<bool> OnMiniMapChangeFullScreenState(bool fullScreen)Fired when the mini-map toggles full-screen mode.
UnityEvent<Vector3, int> OnMiniMapMouseClick(Vector3 worldPosition, int buttonIndex)Fired when the mini-map is clicked. Receives world position and button index.
UnityEvent<Vector2> OnMiniMapMouseEnter(Vector2 screenPosition)Fired when the mouse enters the mini-map area. Receives the screen position.
UnityEvent<Vector2> OnMiniMapMouseExit(Vector2 screenPosition)Fired when the mouse exits the mini-map area. Receives the screen position.
UnityEvent OnMiniMapBeforeCapture()Fired just before the scene is captured for the mini-map. Useful for toggling objects or layers.
UnityEvent OnMiniMapAfterCapture()Fired just after the scene is captured for the mini-map.
UnityEvent<ScanEffect, CompassProPOI, Transform> OnScanHit(ScanEffect scan, CompassProPOI poi, Transform hitTransform)Fired when the scan effect hits a collider. Receives the scan effect, the POI hit, and the transform of the collider.
UnityEvent<ScanEffect> OnScanEnd(ScanEffect scanEffect)Fired when the scan effect ends.
UnityEvent<CompassProPOI, int> OnPOIMiniMapIconMouseClick(CompassProPOI poi, int buttonIndex)Fired when a mini-map POI icon is clicked.
UnityEvent<CompassProPOI> OnPOIMiniMapIconMouseEnter(CompassProPOI poi)Fired when the mouse enters a POI icon on the mini-map.
UnityEvent<CompassProPOI> OnPOIMiniMapIconMouseExit(CompassProPOI poi)Fired when the mouse exits a POI icon on the mini-map.
UnityEvent<CompassProPOI, int> OnPOIMiniMapIconMouseDown(CompassProPOI poi, int buttonIndex)Fired when a mouse button is pressed on a POI icon on the mini-map. The int parameter is the button index.
UnityEvent<CompassProPOI, int> OnPOIMiniMapIconMouseUp(CompassProPOI poi, int buttonIndex)Fired when a mouse button is released on a POI icon on the mini-map. The int parameter is the button index.
UnityEvent<CompassProPOI> UnityEvent<CompassProPOI, GameObject> OnMiniMapIconCreated(CompassProPOI poi, GameObject iconGO)Fired when a minimap icon is created for a POI. Use this to customize the icon GameObject after creation.
UnityEvent<CompassProPOI> OnPOIVisibleInMiniMap(CompassProPOI poi)Fired when a POI appears in the mini-map.
UnityEvent<CompassProPOI> OnPOIHidesInMiniMap(CompassProPOI poi)Fired when a POI disappears from the mini-map.
Code Examples
using UnityEngine;
using CompassNavigatorPro;
public class CompassDemo : MonoBehaviour {
void Start() {
CompassPro compass = CompassPro.instance;
// Listen for POI events
compass.OnPOIVisited.AddListener((poi) => {
Debug.Log("Visited: " + poi.title);
});
// Configure mini-map
compass.showMiniMap = true;
compass.miniMapLocation = MiniMapPosition.BottomRight;
compass.miniMapSize = 0.25f;
// Enable fog of war
compass.fogOfWarEnabled = true;
compass.fogOfWarAutoClear = true;
compass.fogOfWarAutoClearRadius = 50f;
}
// Dynamically create a POI
void CreatePOI(Vector3 position, string name) {
GameObject poiObj = new GameObject(name);
poiObj.transform.position = position;
CompassProPOI poi = poiObj.AddComponent<CompassProPOI>();
poi.title = name;
poi.iconNonVisited = myIcon;
poi.visibility = POIVisibility.WhenInRange;
poi.showOnScreenIndicator = true;
poi.showOffScreenIndicator = true;
}
// Reveal fog around a position
void RevealArea(Vector3 position) {
CompassPro.instance.SetFogOfWarAlpha(position, 30f, 0f, 5f);
}
}
Suggest an improvement
Help us improve this documentation page.