void Start() { DebugPrint("Starting Camera Focus Changer"); flightCamera = FlightCamera.fetch; pivotTranslateSharpness = 0.5f; hasReachedTarget = false; isFocusing = false; PluginConfiguration config = PluginConfiguration.CreateForType <CameraFocusChanger>(); config.load(); //actionKey = config.GetValue<KeyCode>("actionKey", KeyCode.O); if (!LoadCfg()) { SaveCfg(); } showUpdateMessage = config.GetValue <bool>("showUpdateMessage", true); GameEvents.OnCameraChange.Add(OnCameraChange); GameEvents.onVesselChange.Add(OnVesselChange); GameEvents.onVesselWillDestroy.Add(OnVesselWillDestroy); GameEvents.onVesselGoOnRails.Add(OnVesselGoOnRails); GameEvents.onStageSeparation.Add(OnStageSeparation); GameEvents.onUndock.Add(OnUndock); API.SetInstance(this); }
void OnDestroy() { DebugPrint("Disabled"); GameEvents.OnCameraChange.Remove(OnCameraChange); GameEvents.onVesselChange.Remove(OnVesselChange); GameEvents.onVesselWillDestroy.Remove(OnVesselWillDestroy); GameEvents.onVesselGoOnRails.Remove(OnVesselGoOnRails); GameEvents.onStageSeparation.Remove(OnStageSeparation); GameEvents.onUndock.Remove(OnUndock); API.SetInstance(null); }