public void Start() { if (HighLogic.LoadedSceneIsEditor) { return; } try { rpmComp = RasterPropMonitorComputer.Instantiate(internalProp, true); if (!string.IsNullOrEmpty(odometerMode) && modeList.ContainsKey(odometerMode)) { oMode = modeList[odometerMode]; } //else if (!string.IsNullOrEmpty(odometerMode)) { // JUtil.LogMessage(this, "found odometerMode {0}, but it's not in the dictionary", odometerMode); //} //else { // JUtil.LogMessage(this, "Did not find odometerMode"); //} if (string.IsNullOrEmpty(characterTexture) && oMode == OdometerMode.SI) { JUtil.LogErrorMessage(this, "Prop configured as SI scaled, but there is no characterTexture"); return; } if (string.IsNullOrEmpty(digitTexture)) { // We can't do anything without the digit texture JUtil.LogErrorMessage(this, "Prop can not function without a digitTexture"); return; } digitTex = GameDatabase.Instance.GetTexture(digitTexture.EnforceSlashes(), false); if (digitTex == null) { JUtil.LogErrorMessage(this, "Failed to load digitTexture {0}", digitTexture); return; } if (!string.IsNullOrEmpty(characterTexture)) { characterTex = GameDatabase.Instance.GetTexture(characterTexture.EnforceSlashes(), false); if (characterTex == null) { JUtil.LogErrorMessage(this, "Failed to load characterTexture {0}", characterTexture); return; } } if (!string.IsNullOrEmpty(overlayTexture)) { overlayTex = GameDatabase.Instance.GetTexture(overlayTexture.EnforceSlashes(), false); if (overlayTex == null) { JUtil.LogErrorMessage(this, "Failed to load overlayTexture {0}", overlayTexture); return; } } if (string.IsNullOrEmpty(altVariable) != string.IsNullOrEmpty(perPodPersistenceName)) { JUtil.LogErrorMessage(this, "Both altVariable and perPodPeristenceName must be defined, or neither"); return; } // MOARdV: Which one are we using? HUD uses the latter, OrbitDisplay, the former. Shader unlit = Shader.Find("KSP/Alpha/Unlit Transparent"); //Shader unlit = Shader.Find("Hidden/Internal-GUITexture"); digitMaterial = new Material(unlit); backgroundColorValue = ConfigNode.ParseColor32(backgroundColor); lastUpdate = Planetarium.GetUniversalTime(); screenTexture = new RenderTexture(screenPixelWidth, screenPixelHeight, 24, RenderTextureFormat.ARGB32); screenMat = internalProp.FindModelTransform(screenTransform).GetComponent<Renderer>().material; foreach (string layerID in textureLayerID.Split()) { screenMat.SetTexture(layerID.Trim(), screenTexture); } startupComplete = true; } catch { JUtil.AnnoyUser(this); throw; } }
public void Start() { if (HighLogic.LoadedSceneIsEditor) { return; } try { if (!string.IsNullOrEmpty(odometerMode) && modeList.ContainsKey(odometerMode)) { oMode = modeList[odometerMode]; } //else if (!string.IsNullOrEmpty(odometerMode)) { // JUtil.LogMessage(this, "found odometerMode {0}, but it's not in the dictionary", odometerMode); //} //else { // JUtil.LogMessage(this, "Did not find odometerMode"); //} if (string.IsNullOrEmpty(characterTexture) && oMode == OdometerMode.SI) { JUtil.LogErrorMessage(this, "Prop configured as SI scaled, but there is no characterTexture"); return; } if (string.IsNullOrEmpty(digitTexture)) { // We can't do anything without the digit texture JUtil.LogErrorMessage(this, "Prop can not function without a digitTexture"); return; } digitTex = GameDatabase.Instance.GetTexture(digitTexture.EnforceSlashes(), false); if (digitTex == null) { JUtil.LogErrorMessage(this, "Failed to load digitTexture {0}", digitTexture); return; } if (!string.IsNullOrEmpty(characterTexture)) { characterTex = GameDatabase.Instance.GetTexture(characterTexture.EnforceSlashes(), false); if (characterTex == null) { JUtil.LogErrorMessage(this, "Failed to load characterTexture {0}", characterTexture); return; } } if (!string.IsNullOrEmpty(overlayTexture)) { overlayTex = GameDatabase.Instance.GetTexture(overlayTexture.EnforceSlashes(), false); if (overlayTex == null) { JUtil.LogErrorMessage(this, "Failed to load overlayTexture {0}", overlayTexture); return; } } if (string.IsNullOrEmpty(altVariable) != string.IsNullOrEmpty(perPodPersistenceName)) { JUtil.LogErrorMessage(this, "Both altVariable and perPodPeristenceName must be defined, or neither"); return; } // MOARdV: Which one are we using? HUD uses the latter, OrbitDisplay, the former. Shader unlit = Shader.Find("KSP/Alpha/Unlit Transparent"); //Shader unlit = Shader.Find("Hidden/Internal-GUITexture"); digitMaterial = new Material(unlit); rpmComp = RasterPropMonitorComputer.Instantiate(internalProp); backgroundColorValue = ConfigNode.ParseColor32(backgroundColor); lastUpdate = Planetarium.GetUniversalTime(); screenTexture = new RenderTexture(screenPixelWidth, screenPixelHeight, 24, RenderTextureFormat.ARGB32); screenMat = internalProp.FindModelTransform(screenTransform).renderer.material; foreach (string layerID in textureLayerID.Split()) { screenMat.SetTexture(layerID.Trim(), screenTexture); } startupComplete = true; } catch { JUtil.AnnoyUser(this); throw; } }