UIPopup

Code examples to perform various interactions with the UIPopup

Cancel Auto Hide

Cancel an auto hide, if it was initiated

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIPopup MyPopup;

    private void Start()
    {
        MyPopup.CancelAutoHide();
    }
}

Get Target Canvas

Get the TargetCanvas designated for a target UIPopup

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIPopup MyPopup;

    private void Start()
    {
        UICanvas targetCanvas = MyPopup.GetTargetCanvas();
    }
}

Hide Popup

Hide an UIPopup

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIPopup MyPopup;

    private void Start()
    {
        MyPopup.Hide();
    }
}

Hide Popup – instantly (without animation)

Hide an UIPopup instantly without playing the hide animation

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIPopup MyPopup;

    private void Start()
    {
        MyPopup.Hide(true);
    }
}

Show Popup

Show an UIPopup

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIPopup MyPopup;

    private void Start()
    {
        MyPopup.Show();
    }
}

Show Popup – instantly (without animation)

Show an UIPopup instantly without playing the show animation.

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIPopup MyPopup;

    private void Start()
    {
        MyPopup.Show(true);
    }
}

Reset Traget Canvas to Popup Canvas

Reset a target UIPopup’s DisplayTarget to the PopupCanvas (the default canvas used for all UIPopups)

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIPopup MyPopup;

    private void Start()
    {
        MyPopup.ResetTargetCanvasToPopupCanvas();
    }
}

Set Target Canvas Name

Set a new target canvas name and also re-parents the UIPopup under it (if the option is enabled)

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public UIPopup MyPopup;
    public string TargetCanvasName = "MyCanvas";

    private void Start()
    {
        MyPopup.SetTargetCanvasName(TargetCanvasName);
    }
}

GLOBAL – Get Popup

Looks in the UIPopupManager PopupsDatabase for an UIPopup prefab linked to the given popup name. If found, it instantiates a clone of it and returns a reference to it. Otherwise it returns null

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public string PopupName = "MyPopupName";

    private void Start()
    {
        UIPopup popup = UIPopup.GetPopup(PopupName);
    }
}

GLOBAL – Get Popup Overlay Canvas

Get the UICanvas named ‘PopupCanvas’ and set its render mode to ScreenSpaceOverlay

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    private void Start()
    {
        UICanvas popupCanvas = UIPopup.GetPopupOverlayCanvas();
    }
}

GLOBAL – Hide Popup

Hide the UIPopup with the given popup name

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public string PopupName = "MyPopupName";

    private void Start()
    {
        UIPopup.HidePopup(PopupName);
    }
}

GLOBAL – Hide Popup – instantly (without animation)

Hide, instantly without playing the hide animation, the UIPopup with the given popup name

using Doozy.Engine.UI;
using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    public string PopupName = "MyPopupName";

    private void Start()
    {
        UIPopup.HidePopup(PopupName, true);
    }
}