From d705d9ca1256ccb2a984f1083cb0cdc2ca277785 Mon Sep 17 00:00:00 2001 From: in0finite Date: Fri, 21 Jan 2022 02:27:21 +0100 Subject: [PATCH] make MiniMap a StartupSingleton --- Assets/Scripts/Behaviours/MiniMap.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/Behaviours/MiniMap.cs b/Assets/Scripts/Behaviours/MiniMap.cs index dbf16da0..6e24e170 100644 --- a/Assets/Scripts/Behaviours/MiniMap.cs +++ b/Assets/Scripts/Behaviours/MiniMap.cs @@ -6,7 +6,7 @@ using UnityEngine.UI; namespace SanAndreasUnity.Behaviours { - public class MiniMap : MonoBehaviour + public class MiniMap : StartupSingleton { public const int tileEdge = 12; // width/height of map in tiles public const int tileCount = tileEdge * tileEdge; // number of tiles @@ -15,7 +15,7 @@ namespace SanAndreasUnity.Behaviours public const int mapSize = tileEdge * texSize; // width/height of whole map in px public const int uiSize = 256, uiOffset = 10; - public static MiniMap Instance { get; private set; } + public static MiniMap Instance => Singleton; public Image northImage, outlineImage, @@ -138,10 +138,8 @@ namespace SanAndreasUnity.Behaviours MapTexture.Apply(false, true); } - private void Awake() + protected override void OnSingletonAwake() { - Instance = this; - _canvas = this.GetComponentInParent(); curZoomPercentage = availableZooms[zoomSelector];