public void SetName(int id, string name) { FloatingMenuButton button = null; if (_buttons.TryGetValue(id, out button)) { button.SetName(name); } }
public void AddButton(string name, int value) { if (_buttonPrefab == null) { Debug.LogError("Button prefab is null on " + gameObject.name, gameObject); return; } // Expand the menu size. Used to keep the menu on screen. _rectTransform.sizeDelta = new Vector2(_buttonSize.x, _buttonSize.y * (_buttons.Count + 1)); RectTransform newButtonRectTransform = Instantiate(_buttonPrefab, _rectTransform).GetComponent <RectTransform>(); newButtonRectTransform.localPosition = new Vector3(0, -_buttonSize.y * _buttons.Count, 0); FloatingMenuButton button = newButtonRectTransform.GetComponent <FloatingMenuButton>(); button.Initialize(this, name, value); _buttons.Add(value, button); // TODO: Adjust screen position to ensure options aren't left off-screen }