VOIDCore: Add MethodInPreRenderQueue helper.
VOIDCore: Add MethodInPreRenderQueue helper.

--- a/API/VOIDCore.cs
+++ b/API/VOIDCore.cs
@@ -73,31 +73,82 @@
 		public abstract event VOIDEventHandler onApplicationQuit;
 		public abstract event VOIDEventHandler onSkinChanged;
 		public abstract event VOIDEventHandler onUpdate;
-		public virtual event VOIDEventHandler onGui;
+		public virtual event VOIDEventHandler onPreRender;
 		public virtual event VOIDEventHandler onPostRender;
 
-		public virtual bool MethodInPostRenderQueue(VOIDEventHandler method)
+		public virtual bool MethodInPreRenderQueue(VOIDEventHandler method)
 		{
-			if (this.onGui != null)
+			if (this.onPreRender != null)
 			{
-				ToadicusTools.Logging.PostDebugMessage(this, "Looking for method {0} in onGui", method);
+				ToadicusTools.Logging.PostDebugMessage(this, "Looking in onPreRender for method {0} in onGui", method);
 
-				foreach (var invoker in this.onGui.GetInvocationList())
+				foreach (Delegate invoker in this.onPreRender.GetInvocationList())
 				{
 					ToadicusTools.Logging.PostDebugMessage(this, "Checking invoker {0}", invoker);
 
 					if (invoker == method)
 					{
+						ToadicusTools.Logging.PostDebugMessage(this, "Found match.");
 						return true;
 					}
 				}
 			}
+			#if DEBUG
+			else
+			{
+			ToadicusTools.Logging.PostDebugMessage(this, "this.onPreRender == null");
+			}
+			#endif
+
 
 			return false;
 		}
 
-		public abstract void OnGUI();
-		public abstract void OnPostRender();
+		public virtual bool MethodInPostRenderQueue(VOIDEventHandler method)
+		{
+			if (this.onPostRender != null)
+			{
+				ToadicusTools.Logging.PostDebugMessage(this, "Looking in onPostRender for method {0} in onGui", method);
+
+				foreach (Delegate invoker in this.onPostRender.GetInvocationList())
+				{
+					ToadicusTools.Logging.PostDebugMessage(this, "Checking invoker {0}", invoker);
+
+					if (invoker == method)
+					{
+						ToadicusTools.Logging.PostDebugMessage(this, "Found match.");
+						return true;
+					}
+				}
+			}
+			#if DEBUG
+			else
+			{
+				ToadicusTools.Logging.PostDebugMessage(this, "this.onPostRender == null");
+			}
+			#endif
+
+
+			return false;
+		}
+
+		public void OnGUI()
+		{
+			if (Event.current.type == EventType.Repaint || Event.current.isMouse)
+			{
+				if (this.onPreRender != null)
+				{
+					ToadicusTools.Logging.PostDebugMessage(this, "In OnGUI; doing 'pre draw' stuff");
+					this.onPreRender(this);
+				}
+			}
+
+			if (this.onPostRender != null)
+			{
+				ToadicusTools.Logging.PostDebugMessage(this, "In OnGUI; doing 'post draw' stuff");
+				this.onPostRender(this);
+			}
+		}
 
 		public abstract void SaveConfig();
 

--- a/API/VOIDMaster.cs
+++ b/API/VOIDMaster.cs
@@ -107,16 +107,6 @@
 			this.Core.OnGUI();
 		}
 
-		public virtual void OnPostRender()
-		{
-			if (this.Core == null)
-			{
-				return;
-			}
-
-			this.Core.OnPostRender();
-		}
-
 		public virtual void OnDestroy()
 		{
 			if (this.Core == null)

--- a/API/VOID_HUDModule.cs
+++ b/API/VOID_HUDModule.cs
@@ -93,6 +93,11 @@
 
 		public override void DrawGUI(object sender)
 		{
+			if (this.core == null)
+			{
+				return;
+			}
+
 			VOID_Styles.labelHud.normal.textColor = textColors [ColorIndex];
 
 			GUI.skin = this.core.Skin;

--- a/API/VOID_Module.cs
+++ b/API/VOID_Module.cs
@@ -88,6 +88,22 @@
 
 					return callback.GetInvocationList().Contains((Callback)this.DrawGUI);
 				}*/
+
+				using (var log = ToadicusTools.DebugTools.PooledDebugLogger.New(this))
+				{
+					log.AppendFormat("this.core: {0}\n", this.core != null ? this.core.ToString() : "null");
+					if (this.core != null)
+					{
+						log.AppendFormat("this.core.MethodInPostRenderQueue(this.DrawGUI): {0}\n",
+							this.core.MethodInPostRenderQueue(this.DrawGUI));
+					}
+
+					log.AppendFormat("this.GUIRunning: {0}\n",
+						this.core != null && this.core.MethodInPostRenderQueue(this.DrawGUI));
+
+					log.Print(false);
+				}
+
 				return this.core != null && this.core.MethodInPostRenderQueue(this.DrawGUI);
 			}
 		}
@@ -234,7 +250,7 @@
 
 			ToadicusTools.Logging.PostDebugMessage (string.Format("Adding {0} to the draw queue.", this.GetType().Name));
 			// RenderingManager.AddToPostDrawQueue (3, this.DrawGUI);
-			this.core.onGui += this.DrawGUI;
+			this.core.onPostRender += this.DrawGUI;
 		}
 
 		public virtual void StopGUI()
@@ -244,7 +260,7 @@
 				return;
 			}
 			ToadicusTools.Logging.PostDebugMessage (string.Format("Removing {0} from the draw queue.", this.GetType().Name));
-			this.core.onGui -= this.DrawGUI;
+			this.core.onPostRender -= this.DrawGUI;
 		}
 
 		public abstract void DrawGUI(object sender);
@@ -513,6 +529,11 @@
 
 		public override void DrawGUI(object sender)
 		{
+			if (this.core == null)
+			{
+				return;
+			}
+
 			GUI.skin = this.core.Skin;
 
 			Rect _Pos = this.WindowPos;

--- a/Tools/VOID_DataValue.cs
+++ b/Tools/VOID_DataValue.cs
@@ -109,8 +109,26 @@
 			return (T)this.cache;
 		}
 
-		public virtual string ValueUnitString() {
-			return this.Value.ToString() + this.Units;
+		public virtual string ValueUnitString()
+		{
+			if (this.Value == null || this.Units == null)
+			{
+				using (PooledStringBuilder sb = PooledStringBuilder.Get())
+				{
+					if (this.Value == null)
+					{
+						sb.AppendFormat("{0}: Value is null during ValueUnitString\n", this.Label);
+					}
+					if (this.Units == null)
+					{
+						sb.AppendFormat("{0}: Units is null during ValueUnitString\n", this.Label);
+					}
+
+					ToadicusTools.Logging.PostErrorMessage(sb.ToString());
+				}
+			}
+
+			return string.Format("{0}{1}", this.Value == null ? "NULL" : this.Value.ToString(), this.Units);
 		}
 
 		public virtual void DoGUIHorizontal()

--- a/VOIDCore_Generic.cs
+++ b/VOIDCore_Generic.cs
@@ -320,8 +320,6 @@
 		public override event VOIDEventHandler onApplicationQuit;
 		public override event VOIDEventHandler onSkinChanged;
 		public override event VOIDEventHandler onUpdate;
-		public override event VOIDEventHandler onGui;
-		public override event VOIDEventHandler onPostRender;
 
 		/*
 		 * Methods
@@ -528,24 +526,6 @@
 			}
 		}
 
-		public override void OnGUI()
-		{
-			Logging.PostDebugMessage(this, "In OnGUI");
-			if (this.onGui != null)
-			{
-				this.onGui(this);
-			}
-		}
-
-		public override void OnPostRender()
-		{
-			Logging.PostDebugMessage(this, "In OnPostRender");
-			if (this.onPostRender != null)
-			{
-				this.onPostRender(this);
-			}
-		}
-
 		public void OnDestroy()
 		{
 			IVOID_Module module;
@@ -578,7 +558,7 @@
 			{
 				// RenderingManager.AddToPostDrawQueue(3, this.DrawGUI);
 				Logging.PostDebugMessage(this, "Adding DrawGUI to onGui");
-				this.onGui += this.DrawGUI;
+				this.onPostRender += this.DrawGUI;
 			}
 		}
 

--- a/VOID_HUD.cs
+++ b/VOID_HUD.cs
@@ -58,10 +58,10 @@
 
 			this.Active = true;
 
-			this.leftHUD = new HUDWindow("leftHUD", this.leftHUDWindow, new Rect(Screen.width * .375f - 300f, 0f, 300f, 90f));
+			this.leftHUD = new HUDWindow("leftHUD", this.leftHUDWindow, new Rect((float)Screen.width * .375f - 300f, 0f, 300f, 90f));
 			this.Windows.Add(this.leftHUD);
 
-			this.rightHUD = new HUDWindow("rightHUD", this.rightHUDWindow, new Rect(Screen.width * .625f, 0f, 300f, 90f));
+			this.rightHUD = new HUDWindow("rightHUD", this.rightHUDWindow, new Rect((float)Screen.width * .625f, 0f, 300f, 90f));
 			this.Windows.Add(this.rightHUD);
 
 			Logging.PostDebugMessage ("VOID_HUD: Constructed.");