namespace UIWidgets.Examples
{
using UIWidgets;
using UnityEngine;
using UnityEngine.Serialization;
///
/// Notification and Dialog tests.
///
public class UITestSamples : MonoBehaviour
{
///
/// Question icon.
///
[SerializeField]
[FormerlySerializedAs("questionIcon")]
protected Sprite QuestionIcon;
///
/// Attention icon.
///
[SerializeField]
[FormerlySerializedAs("attentionIcon")]
protected Sprite AttentionIcon;
///
/// Simple notification template.
///
[SerializeField]
[FormerlySerializedAs("notifySimple")]
protected Notify NotifySimpleTemplate;
///
/// Auto-hide notification template.
///
[SerializeField]
[FormerlySerializedAs("notifyAutoHide")]
protected Notify NotifyAutoHideTemplate;
///
/// Sample dialog template.
///
[SerializeField]
[FormerlySerializedAs("dialogSample")]
protected Dialog DialogSampleTemplate;
///
/// Sign-in dialog template.
///
[SerializeField]
[FormerlySerializedAs("dialogSignIn")]
protected Dialog DialogSignInTemplate;
///
/// TreeView dialog template.
///
[SerializeField]
[FormerlySerializedAs("dialogTreeView")]
protected Dialog DialogTreeViewTemplate;
///
/// Popup template.
///
[SerializeField]
[FormerlySerializedAs("popupSample")]
protected Popup PopupTemplate;
///
/// Modal popup template.
///
[SerializeField]
[FormerlySerializedAs("popupModalSample")]
protected Popup PopupModalTemplate;
///
/// Show sticky notification.
///
public void ShowNotifySticky()
{
NotifySimpleTemplate.Clone().Show(
"Sticky Notification. Click on the × above to close.",
customHideDelay: 0f);
}
///
/// Show 3 notification, one by one in this order:
/// - Queue Notification 3
/// - Queue Notification 2
/// - Queue Notification 1
///
public void ShowNotifyStack()
{
NotifySimpleTemplate.Clone().Show(
"Stack Notification 1.",
customHideDelay: 3f,
sequenceType: NotifySequence.First);
NotifySimpleTemplate.Clone().Show(
"Stack Notification 2.",
customHideDelay: 3f,
sequenceType: NotifySequence.First);
NotifySimpleTemplate.Clone().Show(
"Stack Notification 3.",
customHideDelay: 3f,
sequenceType: NotifySequence.First);
}
///
/// Show 3 notification, one by one in this order:
/// - Queue Notification 1.
/// - Queue Notification 2.
/// - Queue Notification 3.
///
public void ShowNotifyQueue()
{
NotifySimpleTemplate.Clone().Show(
"Queue Notification 1.",
customHideDelay: 3f,
sequenceType: NotifySequence.Last);
NotifySimpleTemplate.Clone().Show(
"Queue Notification 2.",
customHideDelay: 3f,
sequenceType: NotifySequence.Last);
NotifySimpleTemplate.Clone().Show(
"Queue Notification 3.",
customHideDelay: 3f,
sequenceType: NotifySequence.Last);
}
///
/// Show only one notification and hide current notifications from sequence, if exists.
/// Will be displayed only Queue Notification 3.
///
public void ShowNotifySequenceClear()
{
NotifySimpleTemplate.Clone().Show(
"Stack Notification 1.",
customHideDelay: 3f,
sequenceType: NotifySequence.First);
NotifySimpleTemplate.Clone().Show(
"Stack Notification 2.",
customHideDelay: 3f,
sequenceType: NotifySequence.First);
NotifySimpleTemplate.Clone().Show(
"Stack Notification 3.",
customHideDelay: 3f,
sequenceType: NotifySequence.First,
clearSequence: true);
}
///
/// Show notify and close after 3 seconds.
///
public void ShowNotifyAutohide()
{
NotifyAutoHideTemplate.Clone().Show("Achievement unlocked. Hide after 3 seconds.", customHideDelay: 3f);
}
bool CallShowNotifyAutohide(DialogBase dialog, int buttonIndex)
{
ShowNotifyAutohide();
return true;
}
///
/// Show notify with rotate animation.
///
public void ShowNotifyAutohideRotate()
{
NotifyAutoHideTemplate.Clone().Show(
"Achievement unlocked. Hide after 4 seconds.",
customHideDelay: 4f,
hideAnimation: NotificationBase.AnimationRotateVertical);
}
///
/// Show notify with collapse animation.
///
public void ShowNotifyBlack()
{
NotifyAutoHideTemplate.Clone().Show(
"Another Notification. Hide after 5 seconds or click on the × above to close.",
customHideDelay: 5f,
hideAnimation: NotificationBase.AnimationCollapseVertical,
slideUpOnHide: false);
}
bool ShowNotifyYes(DialogBase dialog, int buttonIndex)
{
NotifyAutoHideTemplate.Clone().Show("Action on 'Yes' button click.", customHideDelay: 3f);
return true;
}
bool ShowNotifyNo(DialogBase dialog, int buttonIndex)
{
NotifyAutoHideTemplate.Clone().Show("Action on 'No' button click.", customHideDelay: 3f);
return true;
}
///
/// Show simple dialog.
///
public void ShowDialogSimple()
{
var canvas = UtilitiesUI.FindTopmostCanvas(transform).GetComponent