//加入元件 protected void Add(SVInfo <T> info, bool isSort) { mContainer.Add(info); int index = mContainer.Count - 1; info.ID = index; info.Index = index; info.transform.name = index.ToString("D4"); info.transform.parent = mWrapContent.transform; info.transform.localPosition = new Vector3(0, 0, 0); info.transform.localEulerAngles = new Vector3(0, 0, 0); info.transform.localScale = new Vector3(1, 1, 1); if (!mWrapContent.isRepeat) { mWrapContent.minIndex = 0; mWrapContent.maxIndex = index; } if (isSort) { mWrapContent.SortAlphabetically(); } IsDrag = CheckCanDrag(); }
//刪除元件 public void Del(int index, bool isSort = true) { mInfo.RemoveAt(index); if (mInfo.Count < mContainer.Count) { SVInfo <T> info = mContainer[index]; mContainer.RemoveAt(index); DestroyImmediate(info.gameObject); for (int i = 0; i < mContainer.Count; i++) { mContainer[i].ID = i; mContainer[i].name = i.ToString("D4"); } } if (!mWrapContent.isRepeat) { mWrapContent.minIndex = 0; mWrapContent.maxIndex = mInfo.Count - 1; } if (isSort) { mWrapContent.SortAlphabetically(); } IsDrag = CheckCanDrag(); }
//清除元件 public void Clear() { for (int i = 0; i < mContainer.Count; i++) { SVInfo <T> info = mContainer[i]; if (info == null) { continue; } DestroyImmediate(info.gameObject); } mInfo.Clear(); mContainer.Clear(); if (mWrapContent.isRepeat == false) { mWrapContent.minIndex = 0; mWrapContent.maxIndex = 0; } mWrapContent.SortAlphabetically(); }