Closed blowfishpro closed 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.
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.
I think I might have fixed it... not sure though, this system was clearly broken under the hood at some point.
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.
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.
Hallelujah, this is fixed.
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