Clean up logic for popup.

This commit is contained in:
2023-11-23 17:08:46 +08:00
parent 155ce0bb22
commit e9d0f4ce1a
9 changed files with 417 additions and 248 deletions

View File

@@ -0,0 +1,25 @@
using System;
using UnityEngine;
using UnityEngine.UI;
namespace Cryville.Crtr.UI {
public class PopupManager : MonoBehaviour {
static PopupManager s_instance;
public static PopupManager Instance { get { return s_instance; } }
[SerializeField]
GameObject m_popupPrefab;
void Awake() {
if (s_instance != null) {
Destroy(gameObject);
throw new InvalidOperationException("Attempted to initialize a singleton twice.");
}
s_instance = this;
}
public void Create(string msg) {
Instantiate(m_popupPrefab, transform, false).GetComponent<Popup>().Message = msg;
}
}
}