diff --git a/Directory.Build.props b/Directory.Build.props index 5d8014e..8e880a1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 1.5.2 + 1.5.3 netstandard2.1 SpaceWarp 11 diff --git a/SpaceWarp.Core/Patching/ColorsPatch.cs b/SpaceWarp.Core/Patching/ColorsPatch.cs index 5fac92a..c2d8b52 100644 --- a/SpaceWarp.Core/Patching/ColorsPatch.cs +++ b/SpaceWarp.Core/Patching/ColorsPatch.cs @@ -6,6 +6,7 @@ using KSP.Game; using KSP.Modules; using KSP.OAB; +using KSP.Sim.impl; using SpaceWarp.API.Assets; using UnityEngine; @@ -42,6 +43,24 @@ public static void Prefix(IObjectAssemblyAvailablePart obj, ref GameObject prefa } } + [HarmonyPrefix] + [HarmonyPatch(typeof(SimulationObjectView), nameof(SimulationObjectView.InitializeView))] + public static void UpdateColorsInFlight(GameObject instance) + { + foreach (var renderer in instance.GetComponentsInChildren()) + { + var shaderName = renderer.material.shader.name; + if (shaderName is not ("Parts Replace" or "KSP2/Parts/Paintable")) continue; + Material material; + var mat = new Material(Shader.Find(Ksp2OpaquePath)) + { + name = (material = renderer.material).name + }; + mat.CopyPropertiesFromMaterial(material); + renderer.material = mat; + } + } + //Everything below this point will be removed in the next patch private const int Diffuse = 0; private const int Metallic = 1; diff --git a/SpaceWarp.nuspec b/SpaceWarp.nuspec index b6c93a5..d97225f 100644 --- a/SpaceWarp.nuspec +++ b/SpaceWarp.nuspec @@ -2,7 +2,7 @@ SpaceWarp - 1.5.2 + 1.5.3 SpaceWarp contributors false https://raw.githubusercontent.com/SpaceWarp/SpaceWarp/main/LICENSE @@ -23,4 +23,4 @@ - \ No newline at end of file + diff --git a/SpaceWarpBuildTemplate/swinfo.json b/SpaceWarpBuildTemplate/swinfo.json index 706dc62..529c2b2 100644 --- a/SpaceWarpBuildTemplate/swinfo.json +++ b/SpaceWarpBuildTemplate/swinfo.json @@ -6,7 +6,7 @@ "description": "Space-Warp is an API for KSP2 mod developers.", "source": "https://github.com/SpaceWarpDev/SpaceWarp", "version_check": "https://raw.githubusercontent.com/SpaceWarpDev/SpaceWarp/main/SpaceWarpBuildTemplate/swinfo.json", - "version": "1.5.2", + "version": "1.5.3", "dependencies": [ { "id": "UitkForKsp2",