namespace UIWidgets.Examples
{
using UIWidgets;
using UnityEngine;
using UnityEngine.Serialization;
///
/// Test Notify.
///
public class TestNotify : MonoBehaviour
{
///
/// Notification template.
/// Gameobject in Hierarchy window, parent gameobject should have Layout component (recommended EasyLayout)
///
[SerializeField]
[FormerlySerializedAs("notifyPrefab")]
[FormerlySerializedAs("NotifyTemplate")]
protected Notify NotificationTemplate;
///
/// Notification template with custom content.
///
[SerializeField]
protected Notify NotificationTemplateContent;
///
/// Show Notification.
///
public void ShowNotify()
{
NotificationTemplate.Clone().Show("Achievement unlocked. Hide after 3 seconds.", customHideDelay: 3f);
}
///
/// Notification with horizontal collapse animation.
///
public void HorizontalCollapse()
{
NotificationTemplate.Clone().Show("Notification message.", customHideDelay: 3f, hideAnimation: NotificationBase.AnimationCollapseHorizontal, slideUpOnHide: false);
}
///
/// Notification with horizontal rotate animation.
///
public void HorizontalRotate()
{
NotificationTemplate.Clone().Show("Notification message.", customHideDelay: 3f, hideAnimation: NotificationBase.AnimationRotateHorizontal, slideUpOnHide: false);
}
///
/// Notification with slide animation to left.
///
public void SlideLeft()
{
NotificationTemplate.Clone().Show("Notification message.", customHideDelay: 3f, hideAnimation: NotificationBase.AnimationSlideLeft);
}
///
/// Notification with slide animation to right.
///
public void SlideRight()
{
NotificationTemplate.Clone().Show("Notification message.", customHideDelay: 3f, hideAnimation: NotificationBase.AnimationSlideRight);
}
///
/// Notification with slide animation to left.
///
public void SlideLeftCustom()
{
NotificationTemplate.Clone().Show("Notification message.", customHideDelay: 3f, hideAnimation: x => NotificationBase.HideAnimationSlideBase(x, true, -1f, 200f, true));
}
///
/// Notification with slide animation to right.
///
public void SlideRightCustom()
{
NotificationTemplate.Clone().Show("Notification message.", customHideDelay: 3f, hideAnimation: x => NotificationBase.HideAnimationSlideBase(x, true, +1f, 200f, true));
}
///
/// Notification with slide animation to up.
///
public void SlideUp()
{
NotificationTemplate.Clone().Show("Notification message.", customHideDelay: 3f, hideAnimation: NotificationBase.AnimationSlideUp);
}
///
/// Notification with slide animation to down.
///
public void SlideDown()
{
NotificationTemplate.Clone().Show("Notification message.", customHideDelay: 3f, hideAnimation: NotificationBase.AnimationSlideDown);
}
///
/// Custom content.
///
[SerializeField]
protected RectTransform CustomContent;
///
/// Parent of the CustomContent.
///
[SerializeField]
protected RectTransform CustomContentParent;
///
/// Notification with slide animation to down.
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "HAA0603:Delegate allocation from a method group", Justification = "Required.")]
public void Content()
{
CustomContent.gameObject.SetActive(true);
var notify = NotificationTemplateContent.Clone();
notify.Show(
customHideDelay: 3f,
content: CustomContent,
onReturn: ReturnContent);
}
void ReturnContent()
{
CustomContent.SetParent(CustomContentParent);
CustomContent.gameObject.SetActive(false);
}
}
}