void create_sub_items(MenuItem topItem, float fParentRadius, float fParentAngleMin, float fParentAngleMax) { float fInnerRadius = fParentRadius + SubItemRadialPadding; float fOuterRadius = fInnerRadius + SubItemRadialWidth; int nItems = topItem.SubItems.Count; //float fParentAngleSpan = fParentAngleMax - fParentAngleMin; float fParentAngleMid = 0.5f * (fParentAngleMax + fParentAngleMin); //float fSubMenuSpan = 180.0f - (WedgePadding * (float)(nItems-1)); //float fWedgeSpan = fSubMenuSpan / (float)nItems; float fWedgeSpan = 45.0f; float fSubMenuSpan = nItems * fWedgeSpan + (float)(nItems - 1) * WedgePadding; int nSlicesPerWedge = 16; float fCurAngle = fParentAngleMid - fSubMenuSpan * 0.5f; for (int i = 0; i < nItems; ++i) { MenuItem item = topItem.SubItems[i]; Mesh m = MeshGenerators.CreatePuncturedDisc(fInnerRadius, fOuterRadius, nSlicesPerWedge, fCurAngle, fCurAngle + fWedgeSpan); float fMidAngleRad = (fCurAngle + fWedgeSpan * 0.5f) * Mathf.Deg2Rad; Vector2 vMid = new Vector2(Mathf.Cos(fMidAngleRad), Mathf.Sin(fMidAngleRad)); GameObject itemGO = AppendMeshGO(item.Label, m, itemMaterial, menuContainer); itemGO.transform.Rotate(Vector3.right, -90.0f); // ?? topItem.SubItems[i].GO = itemGO; // [TODO] this is to improve font centering. Right now we do absolute centering // but visually this looks wrong because weight of font is below center-y. // Right thing would be to align at top of lowercase letters, rather than center-y // (to fix in future) float fudge = 0.0f; if (nItems == 2 && i == 1) { fudge = -0.1f; } TextLabelGenerator textGen = new TextLabelGenerator() { Text = item.Label, Scale = SubItemTextScale, Translate = vMid * (fInnerRadius + (TextCenterPointFactor + fudge) * SubItemRadialWidth), Align = TextLabelGenerator.Alignment.HVCenter }; List <GameObject> vTextElems = textGen.Generate(); AddVisualElements(vTextElems, true); // actually want these GOs to be parented to itemGO UnityUtil.AddChildren(itemGO, vTextElems, true); itemGO.SetVisible(false); if (item.SubItems != null) { create_sub_items(item, fOuterRadius, fCurAngle, fCurAngle + fWedgeSpan); } fCurAngle += WedgePadding + fWedgeSpan; } }