public void Remove(IMarkerParentObject p_obj) { selected.Remove(p_obj); SelectonViewButton button = button_dict [p_obj]; int indx = buttons.IndexOf(button); button_dict.Remove(p_obj); buttons.Remove(button); button.DeSelect(); Destroy(button.gameObject); for (int i = indx; i < buttons.Count; i++) { buttons [i].transform.position += new Vector3(0, button_dimensions.y); } content.sizeDelta = new Vector2(content.sizeDelta.x, selected.Count * button_dimensions.y); }
public void Add(IMarkerParentObject p_obj) { if (selected.Contains(p_obj) || button_dict.ContainsKey(p_obj)) { return; } SelectonViewButton button = SelectonViewButton.Get(p_obj, this, button_template.gameObject); button.parent = this; content.sizeDelta = new Vector2(content.sizeDelta.x, selected.Count * button_dimensions.y); RectTransform button_rect = button.GetComponent <RectTransform>(); button_rect.SetParent(content); button_rect.anchoredPosition = new Vector3(button_dimensions.x * .5f, -(selected.Count + .5f) * button_dimensions.y); selected.Add(p_obj); buttons.Add(button); button_dict.Add(p_obj, button); }