private void Awake() { if (instance != null) { Logger.log?.Warn($"Instance of {this.GetType().Name} already exists, destroying."); GameObject.DestroyImmediate(this); return; } GameObject.DontDestroyOnLoad(this); instance = this; string path = Path.Combine(UnityGame.UserDataPath, $"{Plugin.Name}.ini"); string backupPath = backupPath = Path.Combine(UnityGame.UserDataPath, Plugin.Name, "OldProfiles"); if (File.Exists(path)) { RootConfig rootConfig = new RootConfig(path); if (!Directory.Exists(backupPath)) { Directory.CreateDirectory(backupPath); } File.Copy(path, Path.Combine(backupPath, $"{Plugin.Name}.ini"), true); File.Delete(path); } ConfigConverter.ProfileConverter(); SceneManager.activeSceneChanged += this.OnActiveSceneChanged; CameraUtilities.CreateMainDirectory(); CameraUtilities.CreateExampleScript(); ConfigConverter.DefaultConfigConverter(); }
public void OnApplicationStart() { _harmony = new Harmony("com.brian91292.beatsaber.cameraplus"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); cameraController = new GameObject("CameraPlusController").AddComponent <CameraPlusController>(); }
private void OnDestroy() { MultiplayerSession.Close(); SceneManager.activeSceneChanged -= this.OnActiveSceneChanged; Logger.log?.Debug($"{name}: OnDestroy()"); instance = null; // This MonoBehaviour is being destroyed, so set the static instance property to null. }