void Start() { // no setup needed in editor mode if (HighLogic.LoadedScene == GameScenes.EDITOR) { return; } // obtain module configuration moduleConfigNode = ConfigUtils.GetModuleConfigNode(internalProp.name, moduleID); // if there's a cover, create it ConfigNode coverConfigNode = moduleConfigNode.GetNode("KVR_COVER"); if (coverConfigNode != null) { buttonCover = new KVR_Cover(internalProp, coverConfigNode); } // create the switch ConfigNode switchConfigNode = moduleConfigNode.GetNode("KVR_SWITCH_MOMENTARY"); if (switchConfigNode != null) { toggleSwitch = new KVR_SwitchMomentary(internalProp, switchConfigNode); } if (toggleSwitch == null) { switchConfigNode = moduleConfigNode.GetNode("KVR_SWITCH_TWO_STATE"); if (switchConfigNode != null) { toggleSwitch = new KVR_SwitchTwoState(internalProp, switchConfigNode); } } if (toggleSwitch == null) { switchConfigNode = moduleConfigNode.GetNode("KVR_SWITCH_THREE_STATE"); if (switchConfigNode != null) { toggleSwitch = new KVR_SwitchThreeState(internalProp, switchConfigNode); } } if (toggleSwitch == null) { throw new ArgumentException("KVR_ToggleSwitch " + internalProp.name + " is missing a switch configuration!"); } toggleSwitch.enabled = (buttonCover == null); // create labels CreateLabels(); }
protected void Start() { // no setup needed in editor mode if (HighLogic.LoadedScene == GameScenes.EDITOR) { return; } // obtain module configuration moduleConfigNode = ConfigUtils.GetModuleConfigNode(internalProp.name, moduleID); // if there's a cover, create it ConfigNode coverConfigNode = moduleConfigNode.GetNode("KVR_COVER"); try { buttonCover = new KVR_Cover(internalProp, coverConfigNode); } catch (Exception e) { #if DEBUG Utils.LogWarning("KVR_PushButton KVR_COVER exception: " + e.ToString()); #endif } // create the button ConfigNode buttonConfigNode = moduleConfigNode.GetNode("KVR_BUTTON"); try { pushButton = new KVR_Button(internalProp, buttonConfigNode); pushButton.enabled = (buttonCover == null); } catch (Exception e) { throw e; } // special effects Transform coloredObjectTransform = internalProp.FindModelTransform(coloredObject); if (coloredObjectTransform != null) { coloredGameObject = coloredObjectTransform.gameObject; coloredGameObjectMaterial = coloredGameObject.GetComponent <MeshRenderer>().sharedMaterial; coloredGameObjectMaterial.SetColor(Shader.PropertyToID("_EmissiveColor"), Color.black); } // create labels CreateLabels(); }