public void Remove() { CelestialBody celestialBody = Tools.GetCelestialBody(body); CityLightsManager.Log("Removing City Lights obj"); Transform transform = Tools.GetScaledTransform(body); if (transform != null) { CityLightsManager.Log("Removing scaled obj"); OverlayRenderer.Remove(transform.gameObject, scaledMat); GameObject.DestroyImmediate(transform.gameObject.GetComponents <ScaledCityComponent>().First(sc => sc.GUID == materialName)); LocalCityComponent lc = FlightCamera.fetch.mainCamera.gameObject.GetComponents <LocalCityComponent>().FirstOrDefault(sc => sc.GUID == materialName); if (lc != null) { GameObject.DestroyImmediate(lc); } } if (mainMenuBody != null) { GameObject.DestroyImmediate(mainMenuBody.GetComponents <ScaledCityComponent>().First(sc => sc.GUID == materialName)); } materialPQS.Remove(); GameEvents.onGameSceneLoadRequested.Remove(SceneLoaded); GameObject.DestroyImmediate(materialPQS); }
public void Remove() { CelestialBody celestialBody = Tools.GetCelestialBody(body); ShadowManager.Log("Removing Shadow obj"); Transform transform = Tools.GetScaledTransform(body); if (transform != null) { GameObject.DestroyImmediate(transform.gameObject.GetComponents <ScaledShadowComponent>().First(sc => sc.GUID == materialName)); LocalShadowComponent lc = FlightCamera.fetch.mainCamera.gameObject.GetComponents <LocalShadowComponent>().FirstOrDefault(sc => sc.GUID == materialName); if (lc != null) { GameObject.DestroyImmediate(lc); } DeferredRenderer.Remove(transform.gameObject, shadowMat); } materialPQS.Remove(); GameObject.DestroyImmediate(materialPQS); GameEvents.onGameSceneLoadRequested.Remove(SceneLoaded); }