private void ApplyToMainMenu() { if (HighLogic.LoadedScene == GameScenes.MAINMENU) { GameObject go = Tools.GetMainMenuObject(body); if (go != mainMenuBody && go != null) { mainMenuBody = go; Renderer r = mainMenuBody.GetComponent <Renderer>(); if (r != null) { scaledMat.SetTexture("_MainTex", r.material.GetTexture("_MainTex")); Light sunlight = GameObject.FindObjectsOfType <Light>().Last(l => l.isActiveAndEnabled); DeferredRenderer.Add(r.gameObject, scaledMat); ScaledCityComponent sc = r.gameObject.AddComponent <ScaledCityComponent>(); sc.Apply(scaledMat, sunlight); CityLightsManager.Log("Applied to main Menu"); } } else if (go == null) { CityLightsManager.Log("Cannot Find to apply to main Menu!"); } else if (mainMenuBody == go) { CityLightsManager.Log("Already Applied to main Menu!"); } } }
public void Apply() { ShadowManager.Log("Applying to " + body); CelestialBody celestialBody = Tools.GetCelestialBody(body); Transform transform = Tools.GetScaledTransform(body); if (transform != null) { Renderer mr = transform.GetComponent <Renderer>(); if (mr != null && hasSurface) { shadowMat = new Material(ShadowShader); GameObject go = new GameObject(); go.name = "EVE Shadows"; materialPQS = go.AddComponent <MaterialPQS>(); localShadowMat = materialPQS.Apply(celestialBody, null, ShadowShader, false, true); //shadowMaterial.ApplyMaterialProperties(shadowMat); shadowMat.SetFloat(ShaderProperties._SunRadius_PROPERTY, (float)(ScaledSpace.InverseScaleFactor * Sun.Instance.sun.Radius)); localShadowMat.SetFloat(ShaderProperties._SunRadius_PROPERTY, (float)(Sun.Instance.sun.Radius)); shadowMat.name = materialName; localShadowMat.name = materialName; shadowMat.renderQueue = (int)Tools.Queue.Geometry + 3; localShadowMat.renderQueue = (int)Tools.Queue.Geometry + 3; DeferredRenderer.Add(mr.gameObject, shadowMat); } ScaledShadowComponent sc = transform.gameObject.AddComponent <ScaledShadowComponent>(); LocalShadowComponent lsc = FlightCamera.fetch.mainCamera.gameObject.AddComponent <LocalShadowComponent>(); List <CelestialBody> casters = new List <CelestialBody>(); if (caster != null) { foreach (String b in caster) { casters.Add(Tools.GetCelestialBody(b)); } } sc.Apply(shadowMat, celestialBody, casters); lsc.Apply(localShadowMat, celestialBody, casters); } ApplyToMainMenu(); GameEvents.onGameSceneLoadRequested.Add(SceneLoaded); if (HighLogic.LoadedScene == GameScenes.MAINMENU) { ApplyToMainMenu(); } }
private void ApplyToMainMenu() { if (HighLogic.LoadedScene == GameScenes.MAINMENU) { GameObject go = Tools.GetMainMenuObject(body); if (go != mainMenuBody && go != null) { mainMenuBody = go; Renderer r = mainMenuBody.GetComponent <Renderer>(); if (r != null) { scaledMat.SetTexture("_MainTex", r.material.GetTexture("_MainTex")); Light sunlight = GameObject.FindObjectsOfType <Light>().Last(l => l.isActiveAndEnabled); DeferredRenderer.Add(r.gameObject, scaledMat); if (mainMenuBody.name.EndsWith("(Clone)")) { // There is a race condition with Kopernicus. Sometimes, it // will have cloned a body that already had clouds. Hide old clouds. for (var c = 0; c < mainMenuBody.transform.childCount; ++c) { var child = mainMenuBody.transform.GetChild(c).gameObject; if (child.name.StartsWith("EVE City Lights") && child.name.EndsWith("(Clone)")) { child.SetActive(false); } } } ScaledCityComponent sc = r.gameObject.AddComponent <ScaledCityComponent>(); sc.Apply(scaledMat, sunlight); CityLightsManager.Log("Applied to main Menu"); } } else if (go == null) { CityLightsManager.Log("Cannot Find to apply to main Menu!"); } else if (mainMenuBody == go) { CityLightsManager.Log("Already Applied to main Menu!"); } } }