editor menuitem can't change variable in in function

Hi All,
if I have a class that works with menuitem inside it I can’t change any variables in the function that opens the menuitem, it gives an “access non-static member”. So in the below code, if I try to use first_draw or MathEngine_TCP from the function internal static void initDesigner( ), however I can from OnGUI.

I’m just learning Unity and c# and think it might be to do the internal static, but am unsure of how I pass items into the initDesigner( ) function can anyone advise? Thanks.

public class Designer_Window : EditorWindow 
{

    bool first_draw = false;
    public MathEngine_TCP tcp = null;


    [MenuItem( " Design Tools/Viwer", false, 0 ) ]
    internal static void initDesigner( )
    {
        var window = ( Designer_Window ) GetWindow ( typeof( Designer_Window ), false, "Design View");
        window.Show( );

        first_draw = false;    <<<<<<<<<<<<<<this is error
    }
       



    void OnGUI () 
    {

You can’t access an instance variable from a static function since the instance variable requires an instance of the class, and static functions don’t belong to an instance.

The simple fix is to make your variable static.

static first_draw = false;