using UnityEngine; using CSharpESP.Drawing; namespace CSharpESP.Renderers { public class NameTagRenderer { public static void Render( Camera camera, Bounds bounds, string entityName, float currentHealth, float maxHealth, Color textColor) { if (!MathUtils.GetScreenRectFromBounds(camera, bounds, out Rect screenRect)) { return; } float dist = MathUtils.GetDistance(camera, bounds.center); string labelText = $"{entityName} [{dist:F0}m]"; // Draw text label centered above the bounding box Vector2 labelPos = new Vector2(screenRect.center.x, screenRect.yMin - 12f); RenderHelper.DrawString(labelPos, labelText, textColor, true); // Draw Health Bar if health parameters are valid if (maxHealth > 0f) { float healthPct = Mathf.Clamp01(currentHealth / maxHealth); float barWidth = Mathf.Max(30f, screenRect.width); float barHeight = 4f; float barX = screenRect.center.x - (barWidth / 2f); float barY = screenRect.yMin - 6f; // Background GUI.color = new Color(0f, 0f, 0f, 0.6f); GUI.DrawTexture(new Rect(barX, barY, barWidth, barHeight), RenderHelper.WhiteTexture); // Health Fill (interpolated green to red) Color healthColor = Color.Lerp(Color.red, Color.green, healthPct); GUI.color = healthColor; GUI.DrawTexture(new Rect(barX, barY, barWidth * healthPct, barHeight), RenderHelper.WhiteTexture); GUI.color = Color.white; } } } }