/* ┌──────────────────────────────────────────────────────────────────┐ │ Author: Ivan Murzak (https://github.com/IvanMurzak) │ │ Repository: GitHub (https://github.com/IvanMurzak/Unity-MCP) │ │ Copyright (c) 2025 Ivan Murzak │ │ Licensed under the Apache License, Version 2.0. │ │ See the LICENSE file in the project root for more information. │ └──────────────────────────────────────────────────────────────────┘ */ #nullable enable using System; using com.IvanMurzak.Unity.MCP.Editor.Utils; using UnityEngine.UIElements; namespace com.IvanMurzak.Unity.MCP.Editor.UI { /// /// Reusable alert panel component backed by the TemplateAlertPanel.uxml template. /// Provides a styled notification panel with title, message, optional list items, and an optional action button. /// public class AlertPanel { private static readonly string[] TemplatePaths = EditorAssetLoader.GetEditorAssetPaths("Editor/UI/uxml/agents/elements/TemplateAlertPanel.uxml"); private readonly Label _title; private readonly Label _message; private readonly VisualElement _itemsContainer; private readonly Button _button; private EventCallback? _buttonClickCallback; /// /// The root visual element of the alert panel. Add this to a parent container. /// public VisualElement Root { get; } /// /// Creates a new alert panel from the UXML template. /// /// The alert title text. /// The alert message text. public AlertPanel(string title, string message) { var template = EditorAssetLoader.LoadAssetAtPath(TemplatePaths) ?? throw new NullReferenceException($"Failed to load TemplateAlertPanel.uxml. Checked: {string.Join(", ", TemplatePaths)}"); var tree = template.CloneTree(); Root = tree.Q("alertPanel") ?? throw new NullReferenceException("VisualElement 'alertPanel' not found in TemplateAlertPanel.uxml."); _title = Root.Q