ImGuiNET / ImGui.NET

An ImGui wrapper for .NET.
MIT License
1.8k stars 298 forks source link

Bad code gen for SlideInt2(), etc. #462

Open noname22 opened 5 months ago

noname22 commented 5 months ago

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.

NoahStolk commented 4 months ago

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.

noname22 commented 4 months ago

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.