Skip to content

Commit 65eaad5

Browse files
author
Christopher-Marcel Böddecker
committed
fix(RadialMenu): buttons have colored background
The radial menu buttons all had a colored background added to them which is white by default. The issue was that a previous commit removed the needed `OnPopulateMesh` method because that one was using a deprecated argument instead of the one it was replaced with. Instead of removing said method this fix makes sure to change the method to take the new argument.
1 parent 92303e1 commit 65eaad5

File tree

1 file changed

+46
-0
lines changed
  • Assets/VRTK/Prefabs/Resources/SubPrefabs/RadialMenuButton

1 file changed

+46
-0
lines changed

Assets/VRTK/Prefabs/Resources/SubPrefabs/RadialMenuButton/UICircle.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,51 @@ protected virtual UIVertex[] SetVbo(Vector2[] vertices, Vector2[] uvs)
6060
}
6161
return vbo;
6262
}
63+
64+
protected override void OnPopulateMesh(VertexHelper vh)
65+
{
66+
float outer = -rectTransform.pivot.x * rectTransform.rect.width;
67+
float inner = -rectTransform.pivot.x * rectTransform.rect.width + thickness;
68+
vh.Clear();
69+
70+
Vector2 prevX = Vector2.zero;
71+
Vector2 prevY = Vector2.zero;
72+
Vector2 uv0 = new Vector2(0, 0);
73+
Vector2 uv1 = new Vector2(0, 1);
74+
Vector2 uv2 = new Vector2(1, 1);
75+
Vector2 uv3 = new Vector2(1, 0);
76+
Vector2 pos0;
77+
Vector2 pos1;
78+
Vector2 pos2;
79+
Vector2 pos3;
80+
float f = (fillPercent / 100f);
81+
float degrees = 360f / segments;
82+
int fa = (int)((segments + 1) * f);
83+
for (int i = -1 - (fa / 2); i < fa / 2 + 1; i++)
84+
{
85+
float rad = Mathf.Deg2Rad * (i * degrees);
86+
float c = Mathf.Cos(rad);
87+
float s = Mathf.Sin(rad);
88+
uv0 = new Vector2(0, 1);
89+
uv1 = new Vector2(1, 1);
90+
uv2 = new Vector2(1, 0);
91+
uv3 = new Vector2(0, 0);
92+
pos0 = prevX;
93+
pos1 = new Vector2(outer * c, outer * s);
94+
if (fill)
95+
{
96+
pos2 = Vector2.zero;
97+
pos3 = Vector2.zero;
98+
}
99+
else
100+
{
101+
pos2 = new Vector2(inner * c, inner * s);
102+
pos3 = prevY;
103+
}
104+
prevX = pos1;
105+
prevY = pos2;
106+
vh.AddUIVertexQuad(SetVbo(new[] { pos0, pos1, pos2, pos3 }, new[] { uv0, uv1, uv2, uv3 }));
107+
}
108+
}
63109
}
64110
}

0 commit comments

Comments
 (0)