コード例 #1
0
 private void Awake()
 {
     if (null != _instance)
     {
         throw new Exception("LifeBarContainer instance already exists.");
     }
     _instance     = this;
     rectTransform = GetComponent <RectTransform>();
 }
コード例 #2
0
    private readonly Dictionary <MobStatus, LifeGauge> _statusLifeBarMap = new Dictionary <MobStatus, LifeGauge>(); // アクティブなライフゲージを保持するコンテナ

    private void Awake()
    {
        // シーン上に1つしか存在させないスクリプトのため、このような疑似シングルトンが成り立つ
        if (null != _instance)
        {
            throw new Exception("LifeBarContainer instance already exists.");
        }
        _instance     = this;
        rectTransform = GetComponent <RectTransform>();
    }