Skip to content
Alexander Shubin edited this page Sep 8, 2022 · 7 revisions

# Dialog

A class for displaying a dialog box. Animated.

The Dialog can be accessed through the RootView instance.

RootView_v2.Instance.dialog

Dialog has three different forms of display:

  • Middle

Can display a description and has a close button, but has only two choices.

The canBeClosedByOutTap parameter indicates whether the window can be closed when clicked outside the dialog box boundary.

    RootView_v2.Instance.dialog.ShowMiddle(
        "Middle Dialog Test!",
        "description",
        "Left", () => Debug.Log("Left - click!"),
        "Right", () => Debug.Log("Right - click!"),
        isCanBeClosedByOutTap);
    public void ShowMiddle(string label, string description, string textLeft, Action onClickLeft, string textRight, Action onClickRight, bool canBeClosedByOutTap = true)
    {
        var contents = new List<DialogButtonContent> { new DialogButtonContent(textLeft, onClickLeft), new DialogButtonContent(textRight, onClickRight) };
        Show(DialogType.Middle, label, description, contents, canBeClosedByOutTap);
    }

middle

  • Middle Multiline

Can display multiple answer choices and highlight them, but does not have a close button and description.

The canBeClosedByOutTap parameter indicates whether the window can be closed when clicked outside the dialog box boundary.

The isWarning parameter is used to highlight the answer choice.

    RootView_v2.Instance.dialog.ShowMiddleMultiline(
        "Middle Multiline Dialog Test!",
        isCanBeClosedByOutTap,
        ("Item 1", () => Debug.Log("Item 1 - click!"), false),
        ("Item 2", () => Debug.Log("Item 2 - click!"), false),
        ("Item 3", () => Debug.Log("Item 3 - click!"), true));
    public void ShowMiddleMultiline(string label, params (string text, Action onClick, bool isWarning)[] buttonContents)
    {
        var contents = buttonContents.Select(t => new DialogButtonContent(t.text, t.onClick, t.isWarning)).ToList();
        Show(DialogType.MiddleMultiline, label, null, contents);
    }

    public void ShowMiddleMultiline(string label, params (string text, Action onClick)[] buttonContents)
    {
        var contents = buttonContents.Select(t => new DialogButtonContent(t.text, t.onClick)).ToList();
        Show(DialogType.MiddleMultiline, label, null, contents);
    }

    public void ShowMiddleMultiline(string label, bool canBeClosedByOutTap, params (string text, Action onClick, bool isWarning)[] buttonContents)
    {
        var contents = buttonContents.Select(t => new DialogButtonContent(t.text, t.onClick, t.isWarning)).ToList();
        Show(DialogType.MiddleMultiline, label, null, contents, canBeClosedByOutTap);
    }

    public void ShowMiddleMultiline(string label, bool canBeClosedByOutTap, params (string text, Action onClick)[] buttonContents)
    {
        var contents = buttonContents.Select(t => new DialogButtonContent(t.text, t.onClick)).ToList();
        Show(DialogType.MiddleMultiline, label, null, contents, canBeClosedByOutTap);
    }

middle_m

  • Bottom Multiline

Can display multiple answer choices and highlight them, but does not have a description.

The canBeClosedByOutTap parameter indicates whether the window can be closed when clicked outside the dialog box boundary.

The isWarning parameter is used to highlight the answer choice.

    RootView_v2.Instance.dialog.ShowBottomMultiline(
        "Bottom Multiline Dialog Test!",
        isCanBeClosedByOutTap,
        ("Item 1", () => Debug.Log("Item 1 - click!"), false),
        ("Item 2", () => Debug.Log("Item 2 - click!"), false),
        ("Item 3", () => Debug.Log("Item 3 - click!"), true),
        ("Item 4", () => Debug.Log("Item 4 - click!"), true));
    public void ShowBottomMultiline(string label, params (string text, Action onClick, bool isWarning)[] buttonContents)
    {
        var contents = buttonContents.Select(t => new DialogButtonContent(t.text, t.onClick, t.isWarning)).ToList();
        Show(DialogType.Bottom, label, null, contents);
    }

    public void ShowBottomMultiline(string label, params (string text, Action onClick)[] buttonContents)
    {
        var contents = buttonContents.Select(t => new DialogButtonContent(t.text, t.onClick)).ToList();
        Show(DialogType.Bottom, label, null, contents);
    }

    public void ShowBottomMultiline(string label, bool canBeClosedByOutTap, params (string text, Action onClick, bool isWarning)[] buttonContents)
    {
        var contents = buttonContents.Select(t => new DialogButtonContent(t.text, t.onClick, t.isWarning)).ToList();
        Show(DialogType.Bottom, label, null, contents, canBeClosedByOutTap);
    }

    public void ShowBottomMultiline(string label, bool canBeClosedByOutTap, params (string text, Action onClick)[] buttonContents)
    {
        var contents = buttonContents.Select(t => new DialogButtonContent(t.text, t.onClick)).ToList();
        Show(DialogType.Bottom, label, null, contents, canBeClosedByOutTap);
    }

bottom_m

You can see an example of Dialog operation in the DialogTest scene.