private void applyConfig(Transform root, TextureSet set, bool useSetColors, bool useIconShaders = false) { if (set == null) { return; } RecoloringData[] colors = useSetColors? set.maskColors : customColors; if (useSetColors) { customColors = set.maskColors; saveColors(customColors); } //apply the texture set to the base model (and trusses?) set.enable(root, colors, useIconShaders); if (stockFairing) { TextureSetMaterialData tsmd = set.textureData[0]; //adjust the already existing fairing materials and fairing panels ModuleProceduralFairing mpf = part.GetComponent <ModuleProceduralFairing>(); if (mpf != null) { Material mat; if (mpf.FairingMaterial != null && mpf.FairingConeMaterial != null) { mat = mpf.FairingMaterial; tsmd.apply(mat, useIconShaders); tsmd.applyRecoloring(mat, colors); mat = mpf.FairingConeMaterial; tsmd.apply(mat, useIconShaders); tsmd.applyRecoloring(mat, colors); } if (mpf.Panels != null && mpf.Panels.Count > 0)//cones are included in regular panels { int len = mpf.Panels.Count; for (int i = 0; i < len; i++) { mat = mpf.Panels[i].mat; tsmd.apply(mat, useIconShaders); tsmd.applyRecoloring(mat, colors); mat = mpf.Panels[i].go.GetComponent <Renderer>().material; tsmd.apply(mat, useIconShaders); tsmd.applyRecoloring(mat, colors); } } } } }
//really, could probably just move this back to the base class, possibly with a config bool for toggling enable of the secondary updates public void Start() { TextureSet ts = TexturesUnlimitedLoader.getTextureSet(textureSet); if (ts != null) { //apply the textur set to the base model, use set-specified mask colors (does not support user recoloring) ts.enable(part.transform.FindRecursive("model"), ts.maskColors); TextureSetMaterialData tsmd = ts.textureData[materialIndex]; //adjust the already existing fairing materials and fairing panels ModuleProceduralFairing mpf = part.GetComponent <ModuleProceduralFairing>(); if (mpf != null) { if (mpf.FairingMaterial != null && mpf.FairingConeMaterial != null) { tsmd.apply(mpf.FairingMaterial); tsmd.apply(mpf.FairingConeMaterial); } if (mpf.Panels != null && mpf.Panels.Count > 0)//cones are included in regular panels { int len = mpf.Panels.Count; for (int i = 0; i < len; i++) { tsmd.apply(mpf.Panels[i].mat); tsmd.apply(mpf.Panels[i].go.GetComponent <Renderer>().material); } } } } //prev shader-only code... //Shader shader = TexturesUnlimitedLoader.getShader(this.shader); //if (mpf != null && shader != null && mpf.FairingMaterial != null) //{ // mpf.FairingMaterial.shader = shader; // if (mpf.FairingConeMaterial != null) { mpf.FairingConeMaterial.shader = shader; } // MonoBehaviour.print("Adjusted MPF materials!"); // if (mpf.Panels != null && mpf.Panels.Count > 0)//cones are included in regular panels // { // int len = mpf.Panels.Count; // for (int i = 0; i < len; i++) // { // mpf.Panels[i].mat.shader = shader; // mpf.Panels[i].go.GetComponent<Renderer>().material.shader = shader; // } // } //} }