ImGui.NET icon indicating copy to clipboard operation
ImGui.NET copied to clipboard

Bad code gen for SlideInt2(), etc.

Open noname22 opened this issue 1 year ago • 2 comments

The code generation seems to have failed for the methods that are supposed to accept multiple ints, ie.

bool DragInt2(string label, ref int v) bool DragInt3(string label, ref int v) bool DragInt4(string label, ref int v)

bool SliderInt2(string label, ref int v, int v_min, int v_max) bool SliderInt3(string label, ref int v, int v_min, int v_max) bool SliderInt4(string label, ref int v, int v_min, int v_max)

etc.

I'm assuming they're supposed to accept multiple ints, not a single one, unless I've gravely misunderstood something.

noname22 avatar Feb 06 '24 22:02 noname22

The generated code is actually correct, although I agree it is a little confusing.

You can use multiple ints because the parameter is a ref int:

static int[] GridColor = [255, 255, 255];

void Render()
{
    // ...
    ImGui.SliderInt3("Grid color", ref GridColor[0], 0, 255);
}

This works correctly in this example, given that the array holds at least 3 items.

NoahStolk avatar Feb 10 '24 21:02 NoahStolk

Alright, thanks for pointing that out. It doesn't really sound very "kosher", though. It should probably accept a span or an array rather than a ref to the first element of the array.

noname22 avatar Feb 10 '24 21:02 noname22