Skip to content

Instantly share code, notes, and snippets.

@Zammy
Created January 31, 2019 07:39
Show Gist options
  • Save Zammy/7f0b1775e4dc8d89d7b858376e5b6755 to your computer and use it in GitHub Desktop.
Save Zammy/7f0b1775e4dc8d89d7b858376e5b6755 to your computer and use it in GitHub Desktop.
Base bootstrapper tightly coupled with ServiceLocator
using UnityEngine;
using System.Collections.Generic;
using MEC;
public class Bootstrapper : MonoBehaviour
{
protected virtual void Awake()
{
}
protected virtual void Start()
{
ServiceLocator.Instance.InitServices();
Timing.RunCoroutine(LateInit());
}
IEnumerator<float> LateInit()
{
yield return Timing.WaitForOneFrame;
ServiceLocator.Instance.LateInitServices();
}
void OnDestroy()
{
ServiceLocator.Instance.DestroyServices();
}
void OnApplicationPause(bool pauseStatus)
{
ServiceLocator.Instance.OnAppPauseServices(pauseStatus);
}
void Update()
{
ServiceLocator.Instance.TickServices(Time.deltaTime, Time.unscaledDeltaTime);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment