Bug #13745

buttons showing up on spacecenter screen when not supposed to

Added by linuxgurugamer about 2 months ago. Updated about 2 months ago.

Target version:
Start date:
% Done:




Sample code designed to show a bug in KSP

This bug started when 1.2.2 was released.

Code which demonstrates the bug and a fix is located here:

I've also attached the zip from Github.

On Github, there are two files in the releases, one shows the bug, the second has code enabled which fixes the bug

Bug happens in the following case:

1. Monobehaviour class instantiated with following code:

[KSPAddon(KSPAddon.Startup.SpaceCentre, true)] // Determines when plugin starts.
public class KSPBugDemo : MonoBehaviour

2. Mod button added, button is NOT supposed to be visible on the main menu:
const ApplicationLauncher.AppScenes scenes =
ApplicationLauncher.AppScenes.FLIGHT |
ApplicationLauncher.AppScenes.MAPVIEW |

_appLauncherButton = applauncher.AddModApplication(
ToggleWindow, // onTrue
ToggleWindow, // onFalse
() => { }, // onHover
() => { }, // onHoverOut
() => { }, // onEnable
() => { }, // onDisable
scenes, // visibleInScenes
GameDatabase.Instance.GetTexture(TexturePath + "spacetux", false) );

Bug is that the button IS visible on the main menu, at least the first time through.

A fix is in the function:
private void FixedUpdate()

which is disabled in the demo.

My best guess is that the button isn't properly initialized when first created in this case
This can be shown by going to any other screen and then returning to the space center, the button
will be properly hidden at that point (27.5 KB) linuxgurugamer, 02/04/2017 03:58 AM


#1 Updated by linuxgurugamer about 2 months ago

Just some more info:

The following is from

With KSP v1.2 full release (build 1586), our "H" button (AppLauncherButton) is showing in some wrong scenes. It's not much of a problem, but it needs to be corrected, as it means something in our code is not right.

The behavior described below in my repro steps is also found with at least one other mod. See here:

As far as I know, we're properly checking for FLIGHT or TRACKINGCENTER before showing the button, and if memory serves that is how it worked up through KSP v1.2 pre-release. See here:

To reproduce this, have build 1586 and HyperEdit v1.5.3 installed.
Notice that our button does not show in the Menu scene (as of yet) - this is proper.
Create/Load a sandbox save.
Notice the "H" button is showing in the Space Center scene - it should not.
Load a ship and launch to the Flight scene.
Notice the button properly shows in all the Flight scene views - this is proper.
Switch back to the Space Center scene.
Notice the button is not showing now - this is proper.
Exit to the Main Menu scene.
Notice the button is now showing here - it should not.

Also available in: Atom PDF