Logo
UI Elements

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

NameTypeDescription
indicatorPresetGameObjectPrefab containing OffScreenIndicatorObject
indicatorIconSpriteOptional icon for the indicator

Settings

NameTypeDescription
trackUIElementboolTracks a UI RectTransform instead of world position
hideWhenOnScreenboolHides indicator when the target is on screen
checkDistancefloatDistance where fading begins or hides indicator
borderOffsetfloatPadding from screen borders
fadeDurationfloatDuration for alpha transitions
transitionEasefloatSmooth damp time for indicator movement

Distance Settings

NameTypeDescription
distanceUnitDistanceUnitNone, Metric, or Imperial
distanceFormatstringFormat for distance display
distanceSourceTransformObject used for distance calculation
enableDistanceFadeboolFade indicator based on distance
fadeStartDistancefloatDistance where fade begins
fadeEndDistancefloatDistance where fade reaches zero

References

NameTypeDescription
targetTransformTransformTarget to track
targetCameraCameraCamera used to convert world to screen position
targetCanvasCanvasCanvas that holds the indicator
rectBoundaryRectTransformOptional boundary region for limiting movement

Public Methods

NameParametersDescription
SetTarget(newTarget)TransformAssigns a new target to track
SetDistanceUnit(unit)DistanceUnitChanges unit system
SetRectBoundary(boundary)RectTransformUses a UI rectangle instead of full screen
Disable()NoneFades out and disables indicator

Code Example

OffScreenIndicatorExample.cs
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();
        }
    }
}

On this page