using System; using UnityEngine.UI; namespace UnityEngine.Rendering.UI { /// /// DebugUIHandler for MessageBox widget. /// public class DebugUIHandlerMessageBox : DebugUIHandlerWidget { /// Name of the widget. public Text nameLabel; DebugUI.MessageBox m_Field; static Color32 k_WarningBackgroundColor = new Color32(231, 180, 3, 30); static Color32 k_WarningTextColor = new Color32(231, 180, 3, 255); static Color32 k_ErrorBackgroundColor = new Color32(231, 75, 3, 30); static Color32 k_ErrorTextColor = new Color32(231, 75, 3, 255); internal override void SetWidget(DebugUI.Widget widget) { base.SetWidget(widget); m_Field = CastWidget(); nameLabel.text = m_Field.displayName; var image = GetComponent(); switch (m_Field.style) { case DebugUI.MessageBox.Style.Warning: image.color = k_WarningBackgroundColor; break; case DebugUI.MessageBox.Style.Error: image.color = k_ErrorBackgroundColor; break; } } void Update() { nameLabel.text = m_Field.message; } /// /// Method called when the box is selected /// /// If is from next /// The previous /// Always returns false, indicating no special handling on selection. public override bool OnSelection(bool fromNext, DebugUIHandlerWidget previous) { return false; } } }