Ejemplo n.º 1
0
 public void SetupTUReflection()
 {
     if (TUAssembly is Assembly)
     {
         TexturesUnlimitedLoaderType = TUAssembly.GetType("KSPShaderTools.TexturesUnlimitedLoader");
         TUTextureContainerType      = TUAssembly.GetType("KSPShaderTools.TextureSetContainer");
         KSPTextureSwitchType        = TUAssembly.GetType("KSPShaderTools.KSPTextureSwitch");
         TextureSetType             = TUAssembly.GetType("KSPShaderTools.TextureSet");
         TextureSetMaterialDataType = TUAssembly.GetType("KSPShaderTools.TextureSetMaterialData");
         ShaderPropertyType         = TUAssembly.GetType("KSPShaderTools.ShaderProperty");
         ShaderPropertyTextureType  = TUAssembly.GetType("KSPShaderTools.ShaderPropertyTexture");
         loadedSets            = TexturesUnlimitedLoaderType.GetField("loadedTextureSets", BindingFlags.Public | BindingFlags.Static).GetValue(null) as IDictionary;
         TUSetRecoloringMethod = KSPTextureSwitchType.GetMethod("setSectionColors");
     }
 }
Ejemplo n.º 2
0
 private void TextureButton(string sTarget, float gap)
 {
     GUILayout.BeginHorizontal();
     if (gap > 0)
     {
         GUILayout.Space(gap);
     }
     if (GUILayout.Button(sTarget))
     {
         PartModule kspTextureSwitchPM = parent.part.Modules["KSPTextureSwitch"];
         string     prev        = CurrentTextureField.GetValue(CurrentTextureField.host) as string;
         var        tuContainer = KSPTextureSwitchType.GetField("textureSets", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(kspTextureSwitchPM);
         var        recolorData = TUTextureContainerType.GetField("customColors", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(tuContainer) as Array;
         CurrentTextureField.SetValue(sTarget, CurrentTextureField.host);
         CurrentTextureField.uiControlEditor.onFieldChanged.Invoke(CurrentTextureField, prev);
         TUSetRecoloringMethod.Invoke(kspTextureSwitchPM, new object[] { string.Empty, recolorData });
         MonoUtilities.RefreshPartContextWindow(parent.part);
     }
     GUILayout.FlexibleSpace();
     GUILayout.EndHorizontal();
 }