Clean up logic for popup.
This commit is contained in:
25
Assets/Cryville/Crtr/UI/PopupManager.cs
Normal file
25
Assets/Cryville/Crtr/UI/PopupManager.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user