Refreshing Values

Refreshing Watch Values

Overview

Jahro's Watcher Mode is designed to constantly keep you updated. The values you're watching are refreshed in line with the Unity's Update loop, meaning the data you see is always up to speed with what's happening in your game.

// Assuming these two objects are initialized and updated somewhere in your game
private GameObject player;
private GameObject enemy;
 
[JahroWatch("Player-Enemy Distance", "Tracks the distance between the player and an enemy", "Gameplay Metrics")]
public float DistanceBetweenPlayerAndEnemy
{
    get 
    {
        if (player != null && enemy != null)
        {
            return Vector3.Distance(player.transform.position, enemy.transform.position);
        }
        else
        {
            return -1;
        }
    }
}

In this example, the DistanceBetweenPlayerAndEnemy property calculates the distance between a player and an enemy in the game world. The value will be refreshed in Watcher Mode every Unity Update, giving you real-time data on how the distance changes during gameplay.

Performance Caution

However, it's important to remember that every system resource comes with a cost. Though Jahro is optimized for performance and refreshes values only when the Watcher tab is active.