using UnityEngine;
using UnityEngine.UI;
namespace ReadyPlayerMe.Core.WebView
{
///
/// This class is responsible for displaying and updating a UI panel and message text.
///
public class MessagePanel : MonoBehaviour
{
[SerializeField] private Text messageLabel;
///
/// Set message from a string value.
///
/// Message to display.
public void SetMessage(string message)
{
messageLabel.text = message;
}
///
/// Set message from a message type.
///
/// Describes the option for the message that is to be displayed.
public void SetMessage(MessageType type)
{
messageLabel.text = type.GetValue();
}
///
/// Set message panel visibility.
///
public void SetVisible(bool visible)
{
gameObject.SetActive(visible);
}
///
/// Set message panel padding in pixels.
///
public void SetMargins(int left, int top, int right, int bottom)
{
var rect = transform as RectTransform;
if (rect != null)
{
rect.offsetMax = new Vector2(-right, -top);
rect.offsetMin = new Vector2(left, bottom);
}
}
}
}