using UnityEngine;
using UnityEngine.UIElements;
///
/// Displays agent information in a popup panel using UI Toolkit
/// Singleton pattern to ensure only one panel is shown at a time
///
public class AgentInfoPanel : MonoBehaviour
{
private static AgentInfoPanel instance;
private static UIDocument uiDocument;
private static VisualElement panelRoot;
private static AIAgent currentAgent;
void Awake()
{
if (instance != null && instance != this)
{
Destroy(gameObject);
return;
}
instance = this;
uiDocument = GetComponent();
if (uiDocument == null)
{
Debug.LogError("AgentInfoPanel: UIDocument component not found!");
return;
}
}
void OnEnable()
{
if (uiDocument == null) return;
panelRoot = uiDocument.rootVisualElement.Q("AgentInfoPanelRoot");
if (panelRoot == null)
{
Debug.LogError("AgentInfoPanel: AgentInfoPanelRoot not found in UXML!");
return;
}
// Hide panel initially
panelRoot.style.display = DisplayStyle.None;
// Setup close button
var closeButton = panelRoot.Q