protected void OnTweenOver() { if (preCenterItem != null) { preCenterItem.SetSelectState(false); } if (curCenterItem != null) { curCenterItem.SetSelectState(true); } }
protected virtual void Awake() { ItemCount = itemList.Count; moveOffsetPerItem = (Mathf.RoundToInt((1f / ItemCount) * 10000f)) * 0.0001f; if (ItemCount % 2 == 0) { mCenterIndex = ItemCount / 2 - 1; } else { mCenterIndex = ItemCount / 2; } int index = 0; for (int i = ItemCount - 1; i >= 0; i--) { UIEnhanceItem item = itemList[i]; item.CurveOffSetIndex = i; item.CenterOffSet = moveOffsetPerItem * (mCenterIndex - index); item.SetSelectState(false); index++; } // set the center item with startCenterIndex if (startCenterIndex < 0 || startCenterIndex >= ItemCount) { startCenterIndex = mCenterIndex; } TotalWidth = ItemSize.x * ItemCount; // sorted items sortedItemList = new List <UIEnhanceItem>(itemList); curCenterItem = itemList[startCenterIndex]; curScrollValue = 0.5f - curCenterItem.CenterOffSet; LerpTweenToTarget(0f, curScrollValue, true); canChangeItem = true; }