using SRDebugger.Services; using SRF.Service; namespace SRDebugger { using UnityEngine; public static class AutoInitialize { #if UNITY_2018 private const RuntimeInitializeLoadType InitializeLoadType = RuntimeInitializeLoadType.BeforeSceneLoad; #else private const RuntimeInitializeLoadType InitializeLoadType = RuntimeInitializeLoadType.SubsystemRegistration; #endif /// /// Initialize the console service before the scene has loaded to catch more of the initialization log. /// [RuntimeInitializeOnLoadMethod(InitializeLoadType)] public static void OnLoadBeforeScene() { // Populate service manager with types from SRDebugger assembly (asmdef) SRServiceManager.RegisterAssembly(); if (Settings.Instance.IsEnabled) { // Initialize console if it hasn't already initialized. SRServiceManager.GetService(); } } /// /// Initialize SRDebugger after the scene has loaded. /// [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)] public static void OnLoad() { if (Settings.Instance.IsEnabled) { SRDebug.Init(); } } } }