using System.Collections.Generic; using UnityEngine; using CSharpESP.Renderers; namespace CSharpESP { [DisallowMultipleComponent] public class ESPManager : MonoBehaviour { public static ESPManager Instance { get; private set; } [Header("Global Settings")] public bool EnableESP = true; public Camera TargetCamera; [Header("Features Toggle")] public bool EnableBox3D = true; public bool EnableBox2D = false; public bool EnableBones = true; public bool EnableNameTags = true; [Header("Colors & Styling")] public Color BoxColor = new Color(0.2f, 0.8f, 1f, 1f); public Color BoneColor = new Color(1f, 1f, 1f, 0.9f); public Color TextColor = Color.white; public float LineThickness = 1.2f; private readonly List m_RegisteredTargets = new List(); private void Awake() { if (Instance != null && Instance != this) { Destroy(gameObject); return; } Instance = this; if (TargetCamera == null) { TargetCamera = Camera.main; } } public void RegisterTarget(Entities.ESPTarget target) { if (!m_RegisteredTargets.Contains(target)) { m_RegisteredTargets.Add(target); } } public void UnregisterTarget(Entities.ESPTarget target) { m_RegisteredTargets.Remove(target); } private void OnGUI() { if (!EnableESP || Event.current.type != EventType.Repaint) return; if (TargetCamera == null) { TargetCamera = Camera.main; if (TargetCamera == null) return; } for (int i = m_RegisteredTargets.Count - 1; i >= 0; i--) { var target = m_RegisteredTargets[i]; if (target == null || !target.isActiveAndEnabled) continue; Bounds bounds = target.GetBounds(); // 1. 3D Bounding Box if (EnableBox3D) { Box3DRenderer.Render(TargetCamera, bounds, BoxColor, LineThickness); } // 2. 2D Bounding Box if (EnableBox2D) { Box2DRenderer.Render(TargetCamera, bounds, BoxColor, Box2DRenderer.BoxStyle.Corner, LineThickness); } // 3. Bones Skeleton if (EnableBones && target.Animator != null) { BoneRenderer.Render(TargetCamera, target.Animator, BoneColor, LineThickness); } // 4. Name & Distance Tags if (EnableNameTags) { NameTagRenderer.Render(TargetCamera, bounds, target.EntityName, target.CurrentHealth, target.MaxHealth, TextColor); } } } } }