IsD3DDeviceLost || g_D3DInsideScene Help?

I keep getting this error when trying to render the GUI but I have no idea how to fix it, what is it?

Me 3, when trying to play a scene Unity crashes. The computer is running windows 7 64bit

m_State.m_DeviceLost || g_D3DInsideScene

(Filename: ..\..\Runtime\GfxDevice\d3d\GfxDeviceD3D9.cpp Line: 1744)


  at (wrapper managed-to-native) System.Diagnostics.StackFrame.get_frame_info (int,bool,System.Reflection.MethodBase&,int&,int&,string&,int&,int&) <0x00004>
  at (wrapper managed-to-native) System.Diagnostics.StackFrame.get_frame_info (int,bool,System.Reflection.MethodBase&,int&,int&,string&,int&,int&) <0xffffffff>
  at System.Diagnostics.StackFrame..ctor (int,bool) <0x0003f>
  at System.Diagnostics.StackTrace.init_frames (int,bool) <0x00082>
  at System.Diagnostics.StackTrace..ctor (int,bool) <0x00012>
  at UnityEngine.StackTraceUtility.ExtractStackTrace () <0x00020>
  at (wrapper runtime-invoke) UnityEngine.StackTraceUtility.runtime_invoke_string (object,intptr,intptr,intptr) <0xffffffff>
Receiving unhandled NULL exception
unity: Launch crash handler

this error normally means that you have a nullrefexection in the editor right before that. look at the error right above this in the log and try to find out where the code flow went after that.

in 99.9% of the cases for me it was in OnGUI cause some data was incorrect or not usable to ongui or a functionality I tried to use, fucking up the whole dx context