static int QPYX_set_constraint_YXQP(IntPtr L_YXQP)
    {
        object QPYX_o_YXQP = null;

        try
        {
            QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1);                        UnityEngine.UI.GridLayoutGroup QPYX_obj_YXQP = (UnityEngine.UI.GridLayoutGroup)QPYX_o_YXQP;
            UnityEngine.UI.GridLayoutGroup.Constraint QPYX_arg0_YXQP = (UnityEngine.UI.GridLayoutGroup.Constraint)ToLua.CheckObject(L_YXQP, 2, typeof(UnityEngine.UI.GridLayoutGroup.Constraint));
            QPYX_obj_YXQP.constraint = QPYX_arg0_YXQP;
            return(0);
        }
        catch (Exception QPYX_e_YXQP)            {
            return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index constraint on a nil value"));
        }
    }
    static int QPYX_get_constraint_YXQP(IntPtr L_YXQP)
    {
        object QPYX_o_YXQP = null;

        try
        {
            QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1);                        UnityEngine.UI.GridLayoutGroup QPYX_obj_YXQP = (UnityEngine.UI.GridLayoutGroup)QPYX_o_YXQP;
            UnityEngine.UI.GridLayoutGroup.Constraint QPYX_ret_YXQP = QPYX_obj_YXQP.constraint;
            ToLua.Push(L_YXQP, QPYX_ret_YXQP);
            return(1);
        }
        catch (Exception QPYX_e_YXQP)            {
            return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index constraint on a nil value"));
        }
    }
    static int set_constraint(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.GridLayoutGroup            obj  = (UnityEngine.UI.GridLayoutGroup)o;
            UnityEngine.UI.GridLayoutGroup.Constraint arg0 = (UnityEngine.UI.GridLayoutGroup.Constraint)ToLua.CheckObject(L, 2, typeof(UnityEngine.UI.GridLayoutGroup.Constraint));
            obj.constraint = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index constraint on a nil value" : e.Message));
        }
    }
    static int get_constraint(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.GridLayoutGroup            obj = (UnityEngine.UI.GridLayoutGroup)o;
            UnityEngine.UI.GridLayoutGroup.Constraint ret = obj.constraint;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index constraint on a nil value" : e.Message));
        }
    }
        static StackObject *set_constraint_9(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.UI.GridLayoutGroup.Constraint value = (UnityEngine.UI.GridLayoutGroup.Constraint) typeof(UnityEngine.UI.GridLayoutGroup.Constraint).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            UnityEngine.UI.GridLayoutGroup instance_of_this_method;
            instance_of_this_method = (UnityEngine.UI.GridLayoutGroup) typeof(UnityEngine.UI.GridLayoutGroup).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.constraint = value;

            return(__ret);
        }
    // Number of rows and cols are only relevant if row/col constraint is used
    public OptionsMenu(
        int rows,
        int cols,
        GameObject cursor,
        MenuEntry[] options,
        Sprite menuImage,
        Font font,
        Constraint constraint = Constraint.FixedRowCount,
        string name           = "Option Menu",
        float width           = 540,
        float height          = 135,
        float posx            = 0,
        float posy            = 0)
        : base(cursor, height, width, posx, posy, name, menuImage, font)
    {
        // Menu dimension
        this.cols = cols;
        this.rows = rows;

        // Create a grid layout
        grid = this.menu.AddComponent <GridLayoutGroup>();

        // Position grid inside background image
        // NOTE: compiler is complaining about double conversion, suck it
        grid.padding.left   = (int)40 + (int)cursorTransform.rect.width;
        grid.padding.right  = 0;
        grid.padding.top    = 24;
        grid.padding.bottom = 12;
        grid.cellSize       = new Vector2(100, 33);
        grid.spacing        = new Vector2(75, 0);

        grid.startAxis  = Axis.Vertical;
        grid.constraint = constraint;

        if (constraint == Constraint.FixedRowCount)
        {
            grid.constraintCount = rows;
            step = rows;
        }
        else if (constraint == Constraint.FixedColumnCount)
        {
            throw new Exception("Fixed column not supported");
            // grid.constraintCount = cols;
            // NOTE: How to deal with horizontal step here?
            // Maybe we should just fix row count forever.
        }

        // Create options
        this.options = new List <MenuEntry>(options);
        float x, y;

        x = 0f;
        y = 0f;

        int borderSize = 32;

        for (int i = 0; i < options.Length; i++)
        {
            options[i].transform.SetParent(this.menu.transform);
            options[i].transform.localScale = new Vector3(1f, 1f, 1f);
        }

        // Resize menu box to fit contents
        Vector2 dim = CalculateGridDimensions(grid);

        x = this.rectTransform.rect.x;
        y = this.rectTransform.rect.y;
        this.rectTransform.sizeDelta = dim;

        // Reposition menu using its size
        this.menu.transform.localPosition =
            new Vector3(0f, -Screen.height / 2 + dim.y, 0f);

        /* NOTE: does not seem to be working */
        // Force layout rebuild to correctly position the cursor
        // LayoutRebuilder.ForceRebuildLayoutImmediate(this.rectTransform);

        // Move cursor to first option
        optionTransform = options[0].gameObject.GetComponent <RectTransform>();
        // PositionCursor(0);

        /* Workaround */
        options[0].StartCoroutine(PositionCursorAfterLayoutUpdate());
    }