void Start() { _dmc = GetComponentInParent <Canvas>().GetComponent <DrivingMenuController>(); _dmc.ShowPanel(false); transform.Find("ReplayButton").GetComponent <Button>().onClick.AddListener(() => Replay()); transform.Find("MenuButton").GetComponent <Button>().onClick.AddListener(() => ShowMenuPanel()); }
void OnDestroy() { _screenRec.StopRecording(); DeleteReplayFile(); _screenRec.OnStopRec -= _replayCam_OnStopRec; foreach (VehicleManager rvm in ReplayerVehicleManagers) { rvm.DestroyVehicle(); } Destroy(CCF); iVehicleManager CM = DrivingPlayManager.Current.PlayerCarManager; Destroy(ReplayCamController); if (ReopenDrivingMenuOnDestroy && CM.goCar != null) { DrivingPlayManager.Current.UnfreezeCars(); CamSelector.Instance.ActiveCam.GetComponentInChildren <Camera>().enabled = true; CamController_Follow_Swing CamFol = CamSelector.Instance.ActiveCam.GetComponent <CamController_Follow_Swing>(); CamFol.target = CM.goCar; CamFol.enabled = true; RaceRecorder.current.State = "Recording"; DrivingPlayManager.Current.UnpauseCars(); DrivingMenuController dmc = _canvas.GetComponent <DrivingMenuController>(); if (dmc == null) { Debug.LogError("dmc is null"); Debug.Break(); } dmc.ShowPanel(true); //Keeps crashing here not any more cos fixed line 44 } }