From b9030174b69b8893cab2df4c9b448c25218418d1 Mon Sep 17 00:00:00 2001 From: s-prechtl Date: Fri, 20 May 2022 08:51:25 +0200 Subject: [PATCH] ItemContainer.cs singleton --- Assets/Scripts/ItemContainer.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Assets/Scripts/ItemContainer.cs b/Assets/Scripts/ItemContainer.cs index bf8e6ef..5f6c5fc 100644 --- a/Assets/Scripts/ItemContainer.cs +++ b/Assets/Scripts/ItemContainer.cs @@ -4,6 +4,20 @@ using System.Collections.Generic; using UnityEngine; public class ItemContainer : MonoBehaviour { + #region Singleton + + public static ItemContainer Instance; + + private void Awake() { + if(Instance != null) { + Debug.LogWarning("More than one instance of ItemContainer found"); + } + + Instance = this; + } + + #endregion + public Item[] allItems; // Start is called before the first frame update public Item GetItemByName(String name) {