ImGuiNET / ImGui.NET

An ImGui wrapper for .NET.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bad code gen for SlideInt2(), etc.

noname22 opened this issue · 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.

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.

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.