Build overlay update for 1.1 GUI changes exp
Build overlay update for 1.1 GUI changes

--- a/QuantumStrut.cs
+++ b/QuantumStrut.cs
@@ -40,7 +40,6 @@
 		Strut strut = null;
 		GameObject lineObj;
 		LineRenderer lr;
-		bool Editor = false;
 		int I = 0;
 
 		#region Fields
@@ -190,21 +189,19 @@
 
 			if (!Util.isValid(LaserMaterial))
 				LaserMaterial = new Material(Shader.Find("Particles/Additive"));
-
-			if (state == StartState.Docked)
-				CheckHit();
-
-			if (state == StartState.Editor)
-			{
-				Editor = true;
-				RenderingManager.AddToPostDrawQueue(0, DrawBuildOverlay);
-				InitLaser();
-			}
-			else
-			{
-				Editor = false;
-				RenderingManager.RemoveFromPostDrawQueue(0, DrawBuildOverlay);
-				DestroyLaser();
+			
+			switch (state)
+			{
+				case StartState.Editor:
+					InitLaser();
+					break;
+				case StartState.Docked:
+					CheckHit();
+					DestroyLaser();
+					break;
+				default:
+					DestroyLaser();
+					break;
 			}
 
 			base.OnStart(state);
@@ -254,6 +251,23 @@
 			base.OnUpdate();
 		}
 
+		public void OnGUI()
+		{
+			if (HighLogic.LoadedSceneIsEditor && Util.isValid(part))
+			{
+				this.DrawBuildOverlay();
+			}
+			else
+			{
+				DestroyLaser();
+			}
+		}
+
+		public void OnDestroy()
+		{
+			DestroyLaser();
+		}
+
 		void CheckHit()
 		{
 			if (HighLogic.LoadedSceneIsEditor)
@@ -343,7 +357,7 @@
 				lr.SetVertexCount(2);
 				lr.SetPosition(0, Vector3.zero);
 				lr.SetPosition(1, Vector3.zero);
-				lr.castShadows = false;
+				lr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
 				lr.receiveShadows = true;
 			}
 		}
@@ -359,44 +373,33 @@
 
 		public void DrawBuildOverlay()
 		{
-			if (Util.isValid(part))
-			{
-				if (!Editor)
-					return;
-
-				if (Util.isValid(lr))
-				{
-					Vector3 dir = getTransform().TransformDirection(Dir);
-					Vector3 start = getTransform().TransformPoint(Start);
-
-					UnityEngine.RaycastHit info = new RaycastHit();
-					bool hit = Physics.Raycast(new UnityEngine.Ray(start + (dir * 0.05f), dir), out info, MaxStrutLength);
-					if (hit && IsEnabled)
-					{
-						if (Util.isValid(material))
-							lr.material = material;
-
-						lr.SetColors(startColor, endColor);
-						lr.SetWidth(StartSize, EndSize);
-
-						lr.SetPosition(0, start);
-						lr.SetPosition(1, info.point);
-					}
-					else
-					{
-						lr.material = LaserMaterial;
-						lr.SetColors(Color.red, Color.red);
-						lr.SetWidth(0.01f, 0.01f);
-
-						lr.SetPosition(0, start);
-						lr.SetPosition(1, start + (dir * MaxStrutLength));
-					}
-				}
-			}
-			else
-			{
-				DestroyLaser();
-				RenderingManager.RemoveFromPostDrawQueue(0, DrawBuildOverlay);
+			if (Util.isValid(lr))
+			{
+				Vector3 dir = getTransform().TransformDirection(Dir);
+				Vector3 start = getTransform().TransformPoint(Start);
+
+				UnityEngine.RaycastHit info = new RaycastHit();
+				bool hit = Physics.Raycast(new UnityEngine.Ray(start + (dir * 0.05f), dir), out info, MaxStrutLength);
+				if (hit && IsEnabled)
+				{
+					if (Util.isValid(material))
+						lr.material = material;
+
+					lr.SetColors(startColor, endColor);
+					lr.SetWidth(StartSize, EndSize);
+
+					lr.SetPosition(0, start);
+					lr.SetPosition(1, info.point);
+				}
+				else
+				{
+					lr.material = LaserMaterial;
+					lr.SetColors(Color.red, Color.red);
+					lr.SetWidth(0.01f, 0.01f);
+
+					lr.SetPosition(0, start);
+					lr.SetPosition(1, start + (dir * MaxStrutLength));
+				}
 			}
 		}
 	}