Merge branch 'master' into PrettyLinesDev2
Merge branch 'master' into PrettyLinesDev2

--- a/ARFlightController.cs
+++ b/ARFlightController.cs
@@ -44,6 +44,8 @@
 		#region Fields
 		protected Dictionary<ConnectionStatus, string> connectionTextures;
 
+		protected ARMapRenderer mapRenderer;
+
 		protected IButton toolbarButton;
 		#endregion
 
@@ -126,6 +128,11 @@
 
 			GameEvents.onGameSceneLoadRequested.Add(this.onSceneChangeRequested);
 			GameEvents.onVesselChange.Add(this.onVesselChange);
+		}
+
+		protected void Start()
+		{
+			this.mapRenderer = MapView.MapCamera.gameObject.AddComponent<ARMapRenderer>();
 		}
 
 		protected void FixedUpdate()
@@ -154,7 +161,7 @@
 				InputLockManager.RemoveControlLock(this.lockID);
 			}
 
-			if (this.toolbarButton != null && HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel != null)
+			if (HighLogic.LoadedSceneIsFlight && this.toolbarButton != null && FlightGlobals.ActiveVessel != null)
 			{
 				List<ModuleLimitedDataTransmitter> relays =
 					FlightGlobals.ActiveVessel.getModulesOfType<ModuleLimitedDataTransmitter>();
@@ -206,6 +213,11 @@
 				this.toolbarButton.Destroy();
 			}
 
+			if (this.mapRenderer != null)
+			{
+				GameObject.Destroy(this.mapRenderer);
+			}
+
 			GameEvents.onGameSceneLoadRequested.Remove(this.onSceneChangeRequested);
 			GameEvents.onVesselChange.Remove(this.onVesselChange);
 		}
@@ -216,7 +228,7 @@
 		{
 			if (scene != GameScenes.FLIGHT)
 			{
-				MonoBehaviour.Destroy(this);
+				MonoBehaviour.DestroyImmediate(this, true);
 			}
 		}
 

file:b/toolbarIcon.xcf (new)
 Binary files /dev/null and b/toolbarIcon.xcf differ