make MiniMap a StartupSingleton

This commit is contained in:
in0finite 2022-01-21 02:27:21 +01:00
parent edbb2e8635
commit d705d9ca12

View file

@ -6,7 +6,7 @@ using UnityEngine.UI;
namespace SanAndreasUnity.Behaviours namespace SanAndreasUnity.Behaviours
{ {
public class MiniMap : MonoBehaviour public class MiniMap : StartupSingleton<MiniMap>
{ {
public const int tileEdge = 12; // width/height of map in tiles public const int tileEdge = 12; // width/height of map in tiles
public const int tileCount = tileEdge * tileEdge; // number of 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 mapSize = tileEdge * texSize; // width/height of whole map in px
public const int uiSize = 256, uiOffset = 10; public const int uiSize = 256, uiOffset = 10;
public static MiniMap Instance { get; private set; } public static MiniMap Instance => Singleton;
public Image northImage, public Image northImage,
outlineImage, outlineImage,
@ -138,10 +138,8 @@ namespace SanAndreasUnity.Behaviours
MapTexture.Apply(false, true); MapTexture.Apply(false, true);
} }
private void Awake() protected override void OnSingletonAwake()
{ {
Instance = this;
_canvas = this.GetComponentInParent<Canvas>(); _canvas = this.GetComponentInParent<Canvas>();
curZoomPercentage = availableZooms[zoomSelector]; curZoomPercentage = availableZooms[zoomSelector];