private void OnScrollChange(float _Offsetpercentage)
        {
            for (int i = 0; i < listTransPerc.Count; i++)
            {
                int index = i;
                TransPercentageStruct itemStruct = listTransPerc[i];
                itemStruct.curveItemData.Percentage += _Offsetpercentage;
                if (itemStruct.curveItemData.Percentage >= 1f)
                {
                    itemStruct.curveItemView.transform.SetAsFirstSibling();

                    // 取出最后一个然后把当前的插入到开头
                    CurveScrollerItemData data = listData.RemoveEnd();
                    float offset = itemStruct.curveItemData.Percentage - 1f;
                    data.Percentage = 0 + offset;

                    listData.AddStart(itemStruct.curveItemData);
                    itemStruct.SetData(data);
                    OnTailChanged?.Invoke();
                }
                else if (itemStruct.curveItemData.Percentage <= 0f)
                {
                    itemStruct.curveItemView.transform.SetAsLastSibling();

                    //往上滑动 取出第一个然后把当前的插到最后一个
                    CurveScrollerItemData data = listData.RemoveStart();
                    listData.Add(itemStruct.curveItemData);

                    float offset = 0f - itemStruct.curveItemData.Percentage;
                    data.Percentage = 1f - offset;
                    itemStruct.SetData(data);
                    OnHeadChanged?.Invoke();
                }
                listTransPerc[index] = itemStruct;
                SetTransPosForTweenPerc(listTransPerc[index].curveItemView.transform, listTransPerc[index].curveItemData.Percentage);
            }
        }
 public abstract void SetData(CurveScrollerItemData t);
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="curveItems"></param>
        public void Init(CurveScrollerItemData[] curveItems)
        {
            if (isInit)
            {
                return;
            }
            if (tweenPath.path.wpLengths.Length <= 1)
            {
                Debug.LogError("tween Path 没有点位信息");
                return;
            }

            isInit = true;
            //获取path总长度
            float pathLength = tweenPath.tween.PathLength();

            //获取每个点的长度 第一个点为0 排除
            float[] needwplengths = new float[tweenPath.path.wpLengths.Length - 1];
            for (int i = 0; i < tweenPath.path.wpLengths.Length; i++)
            {
                //第一个永远是0 不需要
                if (i == 0)
                {
                    continue;
                }
                needwplengths[i - 1] = tweenPath.path.wpLengths[i];
            }

            //添加数据
            //数据过少 就循环添加
            if (curveItems.Length < needwplengths.Length)
            {
                int arrayIndex = 0;
                //多添加一个
                for (int i = 0; i <= needwplengths.Length; i++)
                {
                    listData.Add(curveItems[arrayIndex]);
                    arrayIndex++;
                    if (arrayIndex > curveItems.Length - 1)
                    {
                        arrayIndex = 0;
                    }
                }
            }
            else
            {
                for (int i = 0; i < curveItems.Length; i++)
                {
                    listData.Add(curveItems[i]);
                }
            }

            //计算比例
            basePercentages = new float[needwplengths.Length];
            float tempPercentage = 0;

            for (int i = 0; i < needwplengths.Length; i++)
            {
                tempPercentage    += needwplengths[i] / pathLength;
                basePercentages[i] = tempPercentage;
            }

            for (int i = 0; i < basePercentages.Length; i++)
            {
                //克隆对象
                CurveScrollerItemView cutveItem = Instantiate(curveItemPrefab.gameObject).GetComponent <CurveScrollerItemView>();
                cutveItem.transform.transform.SetParent(this.transform);
                //cutveItem.transform.localScale = Vector3.one;

                CurveScrollerItemData curveItemData = listData.RemoveStart();
                curveItemData.Percentage = basePercentages[i];
                cutveItem.SetData(curveItemData);
                SetTransPosForTweenPerc(cutveItem.transform, basePercentages[i]);

                //添加到列表
                listTransPerc.Add(new TransPercentageStruct(cutveItem, curveItemData));
            }
            listTransPerc.Capacity = listTransPerc.Count;
        }
 public void SetData(CurveScrollerItemData _curveItemData)
 {
     this.curveItemData = _curveItemData;
     curveItemView.SetData(_curveItemData);
 }
 public TransPercentageStruct(CurveScrollerItemView _curveItemView, CurveScrollerItemData _curveItemData)
 {
     this.curveItemView = _curveItemView;
     this.curveItemData = _curveItemData;
 }