Pull up singleton behaviour.
This commit is contained in:
@@ -1,23 +1,11 @@
|
||||
using System;
|
||||
using Cryville.Common.Unity;
|
||||
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; } }
|
||||
|
||||
public class PopupManager : SingletonBehaviour<PopupManager> {
|
||||
[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