Add tracking pins for offscreen targets

This commit is contained in:
Michal Pikulski
2025-12-18 18:49:21 +01:00
parent 70061f7222
commit 905248f85e
30 changed files with 1980 additions and 99 deletions

View File

@@ -0,0 +1,43 @@
using UnityEngine;
namespace UI.Tracking
{
/// <summary>
/// Marks a GameObject as the source point for distance calculations in the tracking system.
/// Typically attached to the player or camera. Only one should be active at a time.
/// </summary>
public class TrackingDistanceSource : MonoBehaviour
{
private static TrackingDistanceSource _instance;
/// <summary>
/// The currently active distance source (typically the player)
/// </summary>
public static TrackingDistanceSource Instance => _instance;
/// <summary>
/// The world position of this distance source
/// </summary>
public Vector3 WorldPosition => transform.position;
private void OnEnable()
{
// Set as the active instance
if (_instance != null && _instance != this)
{
Debug.LogWarning($"[TrackingDistanceSource] Multiple distance sources detected. Overwriting previous instance ({_instance.name}) with {name}");
}
_instance = this;
}
private void OnDisable()
{
// Clear instance if this was the active one
if (_instance == this)
{
_instance = null;
}
}
}
}