#if UNITY_2019_4_OR_NEWER
using JetBrains.Annotations;
using UnityEditor;
using UnityEngine.UIElements;
namespace com.zibra.liquid.Foundation.UIElements
{
///
/// The HelpBox component is a UI Toolkit analog for
/// EditorGUILayout.HelpBox.
///
internal class HelpBox : BindableElement
{
///
[UsedImplicitly]
public new class UxmlFactory : UxmlFactory
{
}
///
public new class UxmlTraits : BindableElement.UxmlTraits {
readonly UxmlStringAttributeDescription m_Text = new UxmlStringAttributeDescription { name = "text" };
readonly UxmlEnumAttributeDescription m_Type =
new UxmlEnumAttributeDescription { name = "type" };
public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
{
base.Init(ve, bag, cc);
((HelpBox)ve).Text = m_Text.GetValueFromBag(bag, cc);
((HelpBox)ve).MessageType = m_Type.GetValueFromBag(bag, cc);
}
}
///
/// The message text.
///
public string Text { get; set; }
///
/// The type of message.
///
public MessageType MessageType { get; set; }
///
/// Creates HelpBox control.
///
public HelpBox()
{
Add(new IMGUIContainer(() =>
{ EditorGUILayout.HelpBox(Text, MessageType, true); }));
}
}
}
#endif