Modal Window
Workflow
The window content will change at runtime depending on its manager. If you want to change these values manually, you can enable the ‘Use Custom Content’ option.
To call the window with a button, you can add a new event using the OnClick callback: Modal Window Object > Modal Window Manager > OpenWindow().
Localization
In order to use the localization system with modal windows, you can select the object and assign a valid localization key. Everything will be handled automatically as long as the localization system is active.
Scripting
using UnityEngine;
using Michsky.DreamOS; // DreamOS namespace
public class SampleClass : MonoBehaviour
{
[SerializeField] private ModalWindowManager myWindow;
[SerializeField] private Sprite icon;
void Start()
{
// Set window icon and text
myWindow.icon = icon;
myWindow.titleText = "New Title";
myWindow.descriptionText = "New Description";
// Enable or disable buttons
myWindow.showCancelButton = true;
myWindow.showConfirmButton = true;
// Apply the changes and update the UI
myWindow.UpdateUI();
// Add window events
myWindow.onConfirm.AddListener(TestFunction);
myWindow.onCancel.AddListener(TestFunction);
myWindow.onOpen.AddListener(TestFunction);
myWindow.onClose.AddListener(TestFunction);
// Open or close the window
myWindow.OpenWindow();
myWindow.CloseWindow();
}
void TestFunction()
{
Debug.Log("Event test");
}
}
How can we help?
A premium WordPress theme with an integrated Knowledge Base,
providing 24/7 community-based support.