Open Shadowblitz16 opened 2 years ago
I've run into this too
Looking through ImGui code, it looks like the logic that pushes the variable would fail:
https://github.com/ocornut/imgui/blob/v1.88/imgui.cpp#L2888-L2900
void ImGui::PushStyleVar(ImGuiStyleVar idx, float val)
{
const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
if (var_info->Type == ImGuiDataType_Float && var_info->Count == 1)
{
ImGuiContext& g = *GImGui;
float* pvar = (float*)var_info->GetVarPtr(&g.Style);
g.StyleVarStack.push_back(ImGuiStyleMod(idx, *pvar));
*pvar = val;
return;
}
IM_ASSERT(0 && "Called PushStyleVar() float variant but variable is not a float!");
}
It's checking if count == 1
which on one of those variables, in the table above the code, it's 2
. I must be missing something because I see the C++ folks in the ImGui issues doing this all the time.
https://github.com/ocornut/imgui/blob/v1.88/imgui.cpp#L2856
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding
Ok.. I've been working through this and I noticed there is a Vector2 overload, that's the one you need to use when the count is 2. Your window padding should be
ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0.0f));
Idk whats going on but
ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding , 0.0f);
crashes even if I pop the same amount of times I push.