Skip to content

Commit

Permalink
Fix #453: enable tube mesh renderers when setting the scale
Browse files Browse the repository at this point in the history
-InternalModel.SetVisible can toggle mesh renderers, and it only gathers components from active objects.  So if we deactivated a tube transform, its renderers might not have been re-enabled properly
  • Loading branch information
JonnyOThan committed Nov 29, 2024
1 parent 4cba22f commit 94fa045
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion FreeIva/InternalModules/Hatches/Hatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,19 @@ void SetTubeScale()
}

bool tubeShouldBeActive = tubeScale > 0 && CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA;

bool tubeWasActive = tubeTransform.gameObject.activeSelf;
tubeTransform.gameObject.SetActive(tubeShouldBeActive);

// InternalModel.SetVisible will enable or disable renderers, but it only touches active objects
// So if we had previously disabled this tube, it may have its renderers disabled and we need to turn them back on
if (tubeShouldBeActive && !tubeWasActive)
{
foreach (MeshRenderer renderer in tubeTransform.GetComponentsInChildren(typeof(MeshRenderer)))
{
renderer.enabled = true;
}
}

if (tubeScale > 0)
{
tubeScale /= tubeDownVectorWorld.magnitude;
Expand Down

0 comments on commit 94fa045

Please sign in to comment.