Off Screen Indicator
A dynamic directional object indicator
Overview
Off Screen Indicator displays an arrow or icon that points toward a target when that target is off screen. It supports UI and 3D world targets, distance readouts, and dynamic fade based on distance.
The system uses an indicator preset containing a visual object (OffScreenIndicatorObject). This object handles icon display, arrow visibility, distance text, rotation, and alpha fading.
Off Screen Indicator is ideal for:
- Showing mission objectives outside the camera view
- Tracking UI or world objects
- Marking items in large levels
The indicator updates every frame and fully handles screen size changes, camera switching, and optional UI boundaries.
Usage
Add Off Screen Indicator component to a GameObject
Assign:
- Target Transform (object to track)
- Target Camera (or leave empty to use Camera.main)
Optionally assign a Rect Boundary to restrict indicator movement to a UI area
The indicator will automatically:
- Detect if target is on or off screen
- Fade in or out based on distance
- Rotate the arrow to point toward the target
- Clamp to borders when off screen
- Follow the target when on screen if desired
Customize Preset
- Locate the Indicator Preset prefab
- Open the prefab and customize it as needed
Create New Presets
You can create different Indicator presets and use them on different objects. To create a new preset:
- Locate the Indicator Preset prefab
- Duplicate the preaab (this is the fastest way to customize)
- Open the new prefab and customize it to your liking
Properties
Indicator
| Name | Type | Description |
|---|---|---|
indicatorPreset | GameObject | Prefab containing OffScreenIndicatorObject |
indicatorIcon | Sprite | Optional icon for the indicator |
Settings
| Name | Type | Description |
|---|---|---|
trackUIElement | bool | Tracks a UI RectTransform instead of world position |
hideWhenOnScreen | bool | Hides indicator when the target is on screen |
checkDistance | float | Distance where fading begins or hides indicator |
borderOffset | float | Padding from screen borders |
fadeDuration | float | Duration for alpha transitions |
transitionEase | float | Smooth damp time for indicator movement |
Distance Settings
| Name | Type | Description |
|---|---|---|
distanceUnit | DistanceUnit | None, Metric, or Imperial |
distanceFormat | string | Format for distance display |
distanceSource | Transform | Object used for distance calculation |
enableDistanceFade | bool | Fade indicator based on distance |
fadeStartDistance | float | Distance where fade begins |
fadeEndDistance | float | Distance where fade reaches zero |
References
| Name | Type | Description |
|---|---|---|
targetTransform | Transform | Target to track |
targetCamera | Camera | Camera used to convert world to screen position |
targetCanvas | Canvas | Canvas that holds the indicator |
rectBoundary | RectTransform | Optional boundary region for limiting movement |
Public Methods
| Name | Parameters | Description |
|---|---|---|
SetTarget(newTarget) | Transform | Assigns a new target to track |
SetDistanceUnit(unit) | DistanceUnit | Changes unit system |
SetRectBoundary(boundary) | RectTransform | Uses a UI rectangle instead of full screen |
Disable() | None | Fades out and disables indicator |
Code Example
using UnityEngine;
using Evo.UI;
public class OffScreenIndicatorExample : MonoBehaviour
{
public OffScreenIndicator indicator;
public Transform objective;
void Start()
{
// Assign target
indicator.SetTarget(objective);
// Use metric units
indicator.SetDistanceUnit(OffScreenIndicator.DistanceUnit.Metric);
// Optional: limit indicator to a UI panel
// indicator.SetRectBoundary(someRectTransform);
}
void Update()
{
// Disable after player reaches objective
if (Vector3.Distance(indicator.distanceSource.position, objective.position) < 2f)
{
indicator.Disable();
}
}
}