From 111a5d74facad79bed05a742fa0bfcc6d95050ad Mon Sep 17 00:00:00 2001 From: Eric Mellino Date: Tue, 18 Oct 2016 01:41:37 -0700 Subject: [PATCH] Fix Styple.Get/SetColor These functions were miscalculating the pointer offset for color elements --- src/ImGui.NET/Style.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ImGui.NET/Style.cs b/src/ImGui.NET/Style.cs index 9d922b3..d0ebfa7 100644 --- a/src/ImGui.NET/Style.cs +++ b/src/ImGui.NET/Style.cs @@ -223,13 +223,19 @@ namespace ImGuiNET /// /// The type of UI element. /// The element's color as currently configured. - public float GetColor(ColorTarget target) => _stylePtr->Colors[(int)target]; + public Vector4 GetColor(ColorTarget target) => *(Vector4*)&_stylePtr->Colors[(int)target * 4]; /// /// Sets the style color for a particular UI element type. /// /// The type of UI element. /// The new color. - public void SetColor(ColorTarget target, float value) => _stylePtr->Colors[(int)target] = value; + public void SetColor(ColorTarget target, Vector4 value) + { + _stylePtr->Colors[(int)target * 4 + 0] = value.X; + _stylePtr->Colors[(int)target * 4 + 1] = value.Y; + _stylePtr->Colors[(int)target * 4 + 2] = value.Z; + _stylePtr->Colors[(int)target * 4 + 3] = value.W; + } } }