Skip to main content
File: Assets/_Molca/_Core/Modals/ModalManager.cs
Type: RuntimeSubsystem (child of RuntimeManager prefab)

When to use

Use ModalManager for built-in modal types (message toasts, confirmation dialogs, loading overlays). For product-specific or complex modals (text input, selection, progress with custom UI), see Shared modals.

Role

Shows informational messages, confirmations, loading overlays, and ShowModal<T> for custom modal types. Prefabs and canvas wiring are assigned on the subsystem component in the Inspector.

Code

using Molca.Modals;
using UnityEngine;

public class ScoreReporter : MonoBehaviour
{
    public void ShowResult(string text)
    {
        ModalManager.Instance.AddMessage(text, ModalManager.MessageType.Default, 5f);
    }
}
Use ModalManager.Instance only after RuntimeManager has created the subsystem (e.g. after await RuntimeManager.WaitForInitialization()). Loading overlays and typed modals use other APIs on the same class.

Troubleshooting

  • Modal does not appear: confirm ModalManager.Instance is not null — the subsystem must exist on the RuntimeManager prefab and runtime must be initialized.
  • Modal appears behind other UI: check canvas sort order; ModalManager typically uses a high-priority canvas.
  • ShowModal<T> returns null: ensure the prefab for type T is registered in the ModalManager component’s prefab list in the Inspector.

Unity Editor

RuntimeManager prefab → ModalManager component with modal prefab references.

ModalManager component in Unity Inspector