ferram4 / Ferram-Aerospace-Research

Aerodynamics model for Kerbal Space Program
Other
238 stars 131 forks source link

Info on persistent toolbar buttons #156

Closed blowfishpro closed 7 years ago

blowfishpro commented 7 years ago

I had to fix a similar issue in SolverEngines. The solution ended up being to remove the event immediately once the button is created: https://github.com/KSP-RO/SolverEngines/blob/e27f34b7759b2c39c0932e0bca58b4238d1793d1/SolverEngines/EnginesGUI/FlightGUI.cs#L315

I am not completely sure as to the cause of this ... if not removing it results in two buttons getting added, then it would seem that the KSPAddon is sticking around between scenes. I'm not sure if this is an issue in KSP or just the way Unity works (something is holding on to a reference and therefore it never gets cleaned up).

Regardless though, I'm pretty sure this will fix the issue. Just needs to be inserted here: https://github.com/ferram4/Ferram-Aerospace-Research/blob/1f3f3ecdecf8fd4629723a998684eabdbd356dc8/FerramAerospaceResearch/FARDebugAndSettings.cs#L158

ferram4 commented 7 years ago

Attempting to implement that only made the buttons hang around even more after the changes that I had just introduced... I suspect it may be smarter to rip all the reliance on GameEvents out and add the buttons some other way.

blowfishpro commented 7 years ago

Odd, SolverEngines seems to be working perfectly after these changes. I might have some time tomorrow, if so I'll try to play around and see what's happening.

ferram4 commented 7 years ago

I think I might have fixed it... not sure though, this system was clearly broken under the hood at some point.

Fl4shblade commented 7 years ago

On the new version. When you return to the main menu after leaving a game there is still a FAR button and when you load a savegame after that, there is 2 FAR buttons in the KSP overview, SPH and VAB. Entering the flight scene removes the extra button.

ferram4 commented 7 years ago

The current status of this is that it is almost completely fixed, except for buttons remaining when returning to the main menu. Still needs work.

ferram4 commented 7 years ago

Hallelujah, this is fixed.