New UI Widgets
1.15.10
  • Overview
  • Widgets Generator
  • Widgets
    • Collections
    • Containers
    • Controls
    • Dialogs
      • DatePicker, DateTimePicker, TimePicker
      • Dialog
      • FileDialog
      • FolderDialog
      • Notifications
      • Pickers
      • Popup
        • Options
        • Show() Method Parameters
        • Minimal code
        • Advanced
        • Async
    • Input
    • Miscellaneous
  • Components
  • Effects
  • Shaders
  • Styles (Skins)
  • Integration
  • Supported Packages
  • Known Problems
  • Support
  • Changelog
  • Games
  • Unity Assets
  • LinkedIn
  • EasyLayout
  • New UI Widgets
New UI Widgets
  • Widgets
  • Popup

Popup

Options

  • Title Text Text (obsolete)

    GameObject to display title. Replaced with the DialogInfo.

  • Content Text Text (obsolete)

    GameObject to display text. Replaced with the DialogInfo.

  • Icon Image (obsolete)

    GameObject to display icon. Replaced with the DialogInfo.

  • Info DialogInfoBase

    Component to display the popup info.

  • CloseButton Button

    Button to close popup.

  • Hide on Modal Click bool

    Close popup on click on the background if the modal option enabled.

Show() Method Parameters

All parameters are optional.
title and message also can be specified with SetInfo() to use formatted strings.
  • title string

    Popup title.
    Can be changed with SetInfo() method.
  • message string

    Popup message.
    Can be changed with SetInfo() method.
  • position Vector3?

    Popup position.
    Can be changed with SetPosition().
  • icon Sprite

    Popup icon.
    Can be changed with SetInfo() method.
  • modal bool

    Modal popup.
    Can be changed with SetModal().
  • modalSprite Sprite

    Background image for the modal popup.
    Can be changed with SetModal().
  • modalColor Color?

    Background color for the modal popup.
    Can be changed with SetModal().
  • canvas Canvas

    Canvas to display popup. Required if popup template is prefab.
    Can be changed with SetCanvas().
  • content RectTransform

    Dialog content. Can be used instead of the message and icon.
    Can be changed with SetContent().
  • onClose Action

    Action to run when dialog closed.
    Can be changed with OnClose field.

Minimal code

// create popup instance
var popup = popupTemplate.Clone();
// show popup
popup.Show();
// specify root canvas if popup cloned from prefab
popup.Show(canvas: canvas);

Advanced

// create popup instance
var popup = popupTemplate.Clone();
// show popup with following parameters
popup.Show(
   title: "Modal popup",
   message: "Simple Modal popup.",
   modal: true,
   modalColor: new Color(0, 0, 0, 0.8f)
);

Async

var popup = popupTemplate.Clone();
await popup.ShowAsync();
Previous Next

© Copyright 2023, Ilia Novikov.

Built with Sphinx using a theme provided by Read the Docs.