From ba7de8bfa64766a16b78ef4052e78e528c24aa72 Mon Sep 17 00:00:00 2001 From: dkavolis <12998363+dkavolis@users.noreply.github.com> Date: Tue, 6 Sep 2022 21:31:40 +0300 Subject: [PATCH] Instead of relying on Unity serialization (which doesn't work here) setup `config` in `Start`. `OnLoad` is also not called when placing parts in the editor. --- .../FARPartGeometry/GeometryPartModule.cs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/FerramAerospaceResearch/FARPartGeometry/GeometryPartModule.cs b/FerramAerospaceResearch/FARPartGeometry/GeometryPartModule.cs index b0d52e39..99b31212 100644 --- a/FerramAerospaceResearch/FARPartGeometry/GeometryPartModule.cs +++ b/FerramAerospaceResearch/FARPartGeometry/GeometryPartModule.cs @@ -57,7 +57,6 @@ namespace FerramAerospaceResearch.FARPartGeometry { - [Serializable] internal struct GeometryPartModuleConfig { public bool forceUseColliders; @@ -112,7 +111,7 @@ public class GeometryPartModule : PartModule, IRescalable private int _sendUpdateTick; private int _meshesToUpdate = -1; - [SerializeField] private GeometryPartModuleConfig config = new(); + private GeometryPartModuleConfig config = new(); public bool HasCrossSectionAdjusters { @@ -216,6 +215,10 @@ private void Start() { destroyed = false; + GeometryPartModule modulePrefab = part.partInfo.partPrefab.FindModuleImplementing(); + if (modulePrefab is not null) + config = modulePrefab.config; + //RebuildAllMeshData(); SetupIGeometryUpdaters(); SetupICrossSectionAdjusters(); @@ -1046,16 +1049,9 @@ public override void OnLoad(ConfigNode node) { base.OnLoad(node); + // Flight passes node from the craft config which is empty, using the loaded prefab instead if (HighLogic.LoadedSceneIsFlight) - { - // Flight passes node from the craft config which is empty, use the loaded prefab instead - GeometryPartModule modulePrefab = part.partInfo.partPrefab.FindModuleImplementing(); - if (modulePrefab is not null) - { - config = modulePrefab.config; - return; - } - } + return; LoadBool(node, "forceUseColliders", ref config.forceUseColliders); LoadBool(node, "forceUseMeshes", ref config.forceUseMeshes);