public void initializeData() { if (!initialized) { debug = new InterstellarDebugMessages(debugMode, "InterstellarMeshSwitch"); // you can't have fuel switching without symmetry, it breaks the editor GUI. if (useFuelSwitchModule) updateSymmetry = true; parseObjectNames(); fuelTankSetupList = ParseTools.ParseIntegers(fuelTankSetups); objectDisplayList = ParseTools.ParseNames(objectDisplayNames); if (useFuelSwitchModule) { fuelSwitch = part.GetComponent<InterstellarFuelSwitch>(); if (fuelSwitch == null) { useFuelSwitchModule = false; debug.debugMessage("no FSfuelSwitch module found, despite useFuelSwitchModule being true"); } } initialized = true; } }
// runs the kind of commands that would normally be in OnStart, if they have not already been run. In case a method is called upon externally, but values have not been set up yet private void initializeData() { if (initialized) return; debug = new InterstellarDebugMessages(debugMode, "InterstellarTextureSwitch2"); // you can't have fuel switching without symmetry, it breaks the editor GUI. if (useFuelSwitchModule) updateSymmetry = true; objectList = ParseTools.ParseNames(objectNames, true); texList = ParseTools.ParseNames(textureNames, true, true, textureRootFolder); mapList = ParseTools.ParseNames(mapNames, true, true, textureRootFolder); textureDisplayList = ParseTools.ParseNames(textureDisplayNames); fuelTankSetupList = ParseTools.ParseIntegers(fuelTankSetups); debug.debugMessage("found " + texList.Count + " textures, using number " + selectedTexture + ", found " + objectList.Count + " objects, " + mapList.Count + " maps"); foreach (String targetObjectName in objectList) { Transform[] targetObjectTransformArray = part.FindModelTransforms(targetObjectName); List<Material> matList = new List<Material>(); foreach (Transform t in targetObjectTransformArray) { if (t != null && t.gameObject.renderer != null) // check for if the object even has a mesh. otherwise part list loading crashes { Material targetMat = t.gameObject.renderer.material; if (targetMat != null && !matList.Contains(targetMat)) matList.Add(targetMat); } } targetMats.Add(matList); } if (useFuelSwitchModule) { fuelSwitch = part.GetComponent<InterstellarFuelSwitch>(); // only looking for first, not supporting multiple fuel switchers if (fuelSwitch == null) { useFuelSwitchModule = false; debug.debugMessage("no InterstellarFuelSwitch module found, despite useFuelSwitchModule being true"); } } initialized = true; }