public void AddSlot(bool ShowRemoveButton) { VideoUrlSlot slot = Instantiate(URLTemplate, Template.transform); slot.gameObject.SetActive(true); slot.GetComponent <RectTransform>().anchoredPosition = new Vector2(Offset.x, Offset.y * UrlSlots.Count); if (!ShowRemoveButton) { slot.RemoveButton.gameObject.SetActive(false); } UrlSlots.Add(slot); AddButton.anchoredPosition = new Vector2(Offset.x, Offset.y * UrlSlots.Count); RecalculateContent(); //Save Save(); }
public void RemoveSlot(VideoUrlSlot slot) { int index = UrlSlots.IndexOf(slot); if (index < 0) { Debug.LogWarning("Warning! Slot is not in the list, this should not happen! \"RemoveSlot()\" @VideoUrlEdit"); return; } for (int i = index + 1; i < UrlSlots.Count; i++) { RectTransform slotTransform = UrlSlots[i].GetComponent <RectTransform>(); slotTransform.anchoredPosition = new Vector2(slotTransform.anchoredPosition.x, slotTransform.anchoredPosition.y - Offset.y); } UrlSlots.Remove(slot); Destroy(slot.gameObject); AddButton.anchoredPosition = new Vector2(Offset.x, Offset.y * UrlSlots.Count); RecalculateContent(); //Save Save(); }