Exemplo n.º 1
0
        public void OnDisable()
        {
            CancelAllSource.Cancel();
            CancelAllSource.Dispose();
            CancelAllSource = null;
            Plugin.log?.Critical($"Disabling BeatSync...");
            SetEvents(false);
            SharedCoroutineStarter.instance.StartCoroutine(BeatSyncController.DestroyAfterFinishing());
            GameObject.Destroy(StatusController);
            BeatSyncController = null;
            StatusController   = null;
#if DEBUG
            TestDestroyed();
#endif
        }
Exemplo n.º 2
0
 public void OnEnable()
 {
     if (!ConfigInitialized)
     {
         Plugin.log.Error($"Config files could not be initialized, unable to start.");
         return;
     }
     if (CancelAllSource != null)
     {
         try
         {
             CancelAllSource.Cancel();
             CancelAllSource.Dispose();
         }
         catch (Exception) { }
     }
     BSMLSettings.instance.AddSettingsMenu("BeatSync", "BeatSync.UI.SettingsUI", SettingsUI);
     CancelAllSource = new CancellationTokenSource();
     Plugin.log?.Debug($"BeatSync {PluginVersion} OnEnable");
     // Check if CustomUI is installed.
     try
     {
         SetEvents(true);
         // Called to set the WebClient SongFeedReaders uses
         if (!SongFeedReaders.WebUtils.IsInitialized)
         {
             var userAgent = $"BeatSync/{PluginVersion}";
             SongFeedReaders.WebUtils.Initialize(new WebUtilities.WebWrapper.WebClientWrapper());
             SongFeedReaders.WebUtils.WebClient.SetUserAgent(userAgent);
             SongFeedReaders.WebUtils.WebClient.Timeout = config.DownloadTimeout * 1000;
             Plugin.log?.Debug($"Initialized WebUtils with User-Agent: {userAgent}");
         }
         BeatSync.Paused    = false;
         BeatSyncController = new GameObject("BeatSync.BeatSync").AddComponent <BeatSync>();
         BeatSyncController.CancelAllToken = CancelAllSource.Token;
         //StatusController = new GameObject("BeatSync.UIController").AddComponent<UI.UIController>();
         //beatSyncCreated = true;
         GameObject.DontDestroyOnLoad(BeatSyncController);
         // GameObject.DontDestroyOnLoad(StatusController);
     }
     catch (Exception ex)
     {
         Plugin.log?.Error(ex);
     }
 }