internal override void Awake() { WindowCaption = "Scatterer mod: alt+f10/f11 toggle"; WindowRect = new Rect(0, 0, 300, 50); Visible = true; isActive = false; if (HighLogic.LoadedScene == GameScenes.TRACKSTATION) { ReactivateAtmosphere (parentPlanet, rimBlend, rimpower); } // savePlanetsList (); if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedScene==GameScenes.SPACECENTER ) { isActive = true; for (int j=0; j<10; j++) { additionalScales[j]=1000f; } for (int j=0;j<10;j++){ debugSettings[j]=false; } //read parent planet from config cfg.load (); parentPlanet =cfg.GetValue<string>("Planet"); atmosphereGlobalScale=float.Parse(cfg.GetValue<string>("atmosphereGlobalScale"))*1000f; //find sun and parent planet celestialBodies = (CelestialBody[])CelestialBody.FindObjectsOfType(typeof(CelestialBody)); PlanetId =0; SunId =0; //Transform transform; // this next bit finds kerbin and the sun, and sets all the plaents to renderqueue 2002 //so they don't get clipped over by the amospheres (renderqueue 2001) for (int k=0; k< celestialBodies.Length ; k++) { // transform = GetScaledTransform (celestialBodies[k].name); // { // mr = (MeshRenderer)transform.GetComponent (typeof(MeshRenderer)); // if (mr != null) // { // mr.material.renderQueue=2002; // } // } if (celestialBodies[k].GetName() == parentPlanet) PlanetId=k; if (celestialBodies[k].GetName() == "Sun") SunId=k; // mr.enabled=false; } m_manager=new Manager(); m_manager.setParentCelestialBody(celestialBodies[PlanetId]); m_manager.setSunCelestialBody(celestialBodies[SunId]); m_manager.SetCore(this); m_manager.Awake(); getSettingsFromSkynode(); m_radius = (float)celestialBodies [PlanetId].Radius; // MeshRenderer sunMR= // (MeshRenderer)celestialBodies[SunId].GetComponent (typeof(MeshRenderer)); // sunMR.enabled=false; } }
internal override void Update() { //toggle whether GUI is visible or not if ((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) && (Input.GetKeyDown(KeyCode.F11)||(Input.GetKeyDown(KeyCode.F10)))) Visible = !Visible; if (isActive) { updateCnt++; if (updateCnt>5){ if (!found) { //debug settings // for (int j=0;j<10;j++){ // debugSettings[j]=false; // } //read parent planet from config cfg.load (); // parentPlanet =cfg.GetValue<string>("Planet"); loadParentPlanet(); atmosphereGlobalScale=float.Parse(cfg.GetValue<string>("atmosphereGlobalScale"))*1000f; //find sun and parent planet celestialBodies = (CelestialBody[])CelestialBody.FindObjectsOfType(typeof(CelestialBody)); PlanetId =0; SunId =0; for (int k=0; k< celestialBodies.Length ; k++) { // print (celestialBodies[k].GetName()); // print ("ParentPlanetCelestialBodyName"); // print (ParentPlanetCelestialBodyName); // if (celestialBodies[k].GetName() == parentPlanet) if (celestialBodies[k].GetName() == ParentPlanetCelestialBodyName) PlanetId=k; if (celestialBodies[k].GetName() == "Sun") SunId=k; } if (PlanetId==0) print("parentPlanet not found"); else found=true; ParentPlanetTransform = ScaledSpace.Instance.transform.FindChild(ParentPlanetTransformName); } if (!initiated && found) { //create and configure manager m_manager=new Manager(); m_manager.setParentCelestialBody(celestialBodies[PlanetId]); m_manager.setParentPlanetTransform(ParentPlanetTransform); m_manager.setSunCelestialBody(celestialBodies[SunId]); m_manager.SetCore(this); m_manager.Awake(); // print ("parentPlanet transform position"); // print (ParentPlanetTransform.position); // // print ("parentcelestialbody transform position"); // print (celestialBodies[PlanetId].transform.position); getSettingsFromSkynode(); loadConfigPoint(selectedConfigPoint); m_radius = (float)celestialBodies [PlanetId].Radius; // backupAtmosphereMaterial(parentPlanet); // tweakStockAtmosphere(parentPlanet,rimBlend,rimpower); backupAtmosphereMaterial(ParentPlanetTransformName); tweakStockAtmosphere(ParentPlanetTransformName,rimBlend,rimpower); // // if (!initiated){ cams = Camera.allCameras; count = Camera.allCameras.Length; initiated=true; } if(initiated) { m_manager.Update (); } } } }