private void ClearList() { for (int i = 0; i < CurrentRadials.Count; i++) { ItemPool.Despawn(CurrentRadials[i].gameObject); } CurrentRadials.Clear(); }
protected void Populate(float targetAngle) { if (Actions.Count <= 0) { Debug.LogError("There are no elements in the layer " + Description); return; } _elementAngleDeg = 360.0f / Actions.Count; _elementAngleRad = _elementAngleDeg * Mathf.Deg2Rad; //_elementArcSize = 2.0f * Mathf.PI * Radial.ScreenSize * (_elementAngleDeg / 360.0f); Vector2[] positions = new Vector2[Actions.Count]; for (int i = 0; i < positions.Length; i++) { positions[i] = new Vector2(); var tempAngle = i * _elementAngleRad; positions[i].x = Radial.ScreenSize * Mathf.Sin(tempAngle); positions[i].y = Radial.ScreenSize * Mathf.Cos(tempAngle); } SelectedIndex = HandleCursor(targetAngle); UpdateDisplayedText(Actions[SelectedIndex].Description, Actions[SelectedIndex].Icon, Color.white); int prevIndex = SelectedIndex == 0 ? Actions.LastIndex() : SelectedIndex - 1; for (var i = 0; i < Actions.Count; i++) { var element = Radial.CreateElement(); CurrentRadials.Add(element); element.AssignParent(Radial, i, Actions[i]); element.RectTr.localPosition = positions[SelectedIndex]; if (i == SelectedIndex) { element.AssignPoints(null); continue; } var pnts = new Vector2[4]; pnts[0] = positions[prevIndex]; pnts[1] = element.RectTr.localPosition; pnts[2] = positions[i]; pnts[3] = i < Actions.Count - 1 ? positions[i + 1] : positions[0]; element.AssignPoints(pnts); } }