/// <summary>
    /// 根据已经存在的项创建其他的项 如果项太多会删除数据
    /// </summary>
    /// <param name="dex"></param>
    /// <returns></returns>
    protected virtual RectTransform CrateGameObject(int dex)
    {
        RectTransform target       = null;
        bool          isCreateItem = false; //标示是否是创建的项or 复用的项

        if (dex < ContentRectrans.childCount)
        {
            target = ContentRectrans.GetChildEX(dex);
        }
        else
        {
            target       = GameObject.Instantiate(mItemPrefab, ContentRectrans).transform as RectTransform;
            isCreateItem = true;
        }
        LoopCircleItem circleItem = target.GetAddComponent <LoopCircleItem>();

        circleItem.InitialedView(dex);
        AllLoopCircleItems[target] = circleItem;

        if (isCreateItem && OnItemCreateAct != null)
        {
            OnItemCreateAct(target, circleItem);
        }
        return(target);
    }
Exemple #2
0
 private void Awake()
 {
     ShowText         = transform.Find("Text").GetComponent <Text>();
     mConfirmButton   = transform.Find("ConfirmButton").GetComponent <Button>();
     m_LoopCircleItem = transform.GetComponent <LoopCircleItem>();
     mConfirmButton.onClick.AddListener(OnButtonClick);
 }
 private void OnDeleteData(LoopCircleItem item)
 {
     //Transform target = mVerticalLoopCircleTween.GetFirstVisibleTrans();
     //if (target == null) return;
     //LoopCircleItem loopCircle = mVerticalLoopCircleTween.GetLoopCircleItemByTrans(target);
     //if (loopCircle == null) return;
     //// 
     //mVerticalLoopCircleTween.RefillData(LooCircledDataManager.Instance.Datas.Count, loopCircle.DataIndex);
 }
    public LoopCircleItem GetLoopCircleItemByTrans(RectTransform target)
    {
        LoopCircleItem result = null;

        if (AllLoopCircleItems.TryGetValue(target, out result))
        {
            return(result);
        }

        Debug.LogError("GetLoopCircleItemByTrans Fail");
        return(null);
    }
Exemple #5
0
    /// <summary>
    /// 根据索引获取可见的项
    /// </summary>
    /// <param name="dex"></param>
    /// <returns></returns>
    public LoopCircleItem GetVisibleLoopItemByIndex(int dex)
    {
        LoopCircleItem result = null;

        if (mAllVisibleLoopItems.TryGetValue(dex, out result))
        {
            return(result);
        }

        Debug.LogError(string.Format("获取可见项失败 没有这个索引:{0} 对应的项 ", dex));
        return(null);
    }
Exemple #6
0
    /// <summary>
    /// 将最后不可见的项移动到第一个
    /// </summary>
    /// <param name="firstItem"></param>
    protected virtual void ScrollUpDirection(RectTransform lastItem, RectTransform firstItem)
    {
        lastItem.SetAsFirstSibling();
        lastItem.anchoredPosition = new Vector2(firstItem.anchoredPosition.x, firstItem.anchoredPosition.y + ItemDistance);

        LoopCircleItem lastloopCircle  = AllLoopCircleItems[lastItem];
        LoopCircleItem firstloopCircle = AllLoopCircleItems[firstItem];

        lastloopCircle.InitialedView(firstloopCircle.DataIndex - 1);

        if (OnItemShowAct != null)
        {
            OnItemShowAct.Invoke(lastItem, lastloopCircle);
        }
    }
    /// <summary>
    /// 将第一个不可见的项移动到末尾
    /// </summary>
    /// <param name="firstItem"></param>
    protected virtual void ScrollRightDirection(RectTransform firstItem, RectTransform lastItem)
    {
        //if (firstItem == null)
        //    firstItem = ContentRectrans.GetChildEX(0);

        firstItem.SetAsLastSibling();
        firstItem.anchoredPosition = new Vector2(lastItem.anchoredPosition.x + ItemDistance, lastItem.anchoredPosition.y);
        LoopCircleItem firstloopCircle = AllLoopCircleItems[firstItem];
        LoopCircleItem lastloopCircle  = AllLoopCircleItems[lastItem];

        firstloopCircle.InitialedView(lastloopCircle.DataIndex + 1);
        if (OnItemShowAct != null)
        {
            OnItemShowAct.Invoke(firstItem, firstloopCircle);
        }
    }
    /// <summary>
    ///将最后一个不可见得项移动到开头
    /// </summary>
    /// <param name="operateItem"></param>
    protected virtual void ScrollLeftDirection(RectTransform lastItem, RectTransform firstItem)
    {
        //if (lastItem == null)
        //    lastItem = ContentRectrans.GetChildEX(ContentRectrans.childCount - 1);
        lastItem.SetAsFirstSibling();
        lastItem.anchoredPosition = new Vector2(firstItem.anchoredPosition.x - ItemDistance, firstItem.anchoredPosition.y);

        LoopCircleItem lastloopCircle  = AllLoopCircleItems[lastItem];
        LoopCircleItem firstloopCircle = AllLoopCircleItems[firstItem];

        lastloopCircle.InitialedView(firstloopCircle.DataIndex - 1);
        if (OnItemShowAct != null)
        {
            OnItemShowAct.Invoke(lastItem, lastloopCircle);
        }
    }
Exemple #9
0
    /// <summary>
    /// 主要用于删除当前数据后 为了保持现有的视图获取需要显示的数据偏移
    /// </summary>
    /// <returns></returns>
    public int GetFristVisibleLoopItemDataIndex()
    {
        RectTransform target = GetFirstVisibleTrans();

        if (target == null)
        {
            return(0);
        }
        LoopCircleItem loopCircle = GetLoopCircleItemByTrans(target);

        if (loopCircle == null)
        {
            return(0);
        }
        return(loopCircle.DataIndex);
    }
    private void OnDeleteData(LoopCircleItem item)
    {
        RectTransform target = m_HorizontialHalfLoopCircleFixdistance.GetFirstVisibleTrans();

        if (target == null)
        {
            return;
        }
        LoopCircleItem loopCircle = m_HorizontialHalfLoopCircleFixdistance.GetLoopCircleItemByTrans(target);

        if (loopCircle == null)
        {
            return;
        }

        //
        m_HorizontialHalfLoopCircleFixdistance.RefillData(LooCircledDataManager.Instance.Datas.Count, loopCircle.DataIndex);
    }
Exemple #11
0
    private void OnDeleteData(LoopCircleItem item)
    {
        Debug.Log("OnDeleteData __" + item.name + "  DataIndex=" + item.DataIndex);

        RectTransform target = m_VerticalHalfLoopCicleTween.GetFirstVisibleTrans();

        if (target == null)
        {
            return;
        }
        LoopCircleItem loopCircle = m_VerticalHalfLoopCicleTween.GetLoopCircleItemByTrans(target);

        if (loopCircle == null)
        {
            return;
        }

        //
        m_VerticalHalfLoopCicleTween.RefillData(LooCircledDataManager.Instance.Datas.Count, loopCircle.DataIndex);
    }
 /// <summary>
 /// 创建 RealShowRectItemCount 个显示的Item项 并保存到AllLoopCircleItems 中
 /// </summary>
 protected virtual void CreatePerfectShowItems()
 {
     for (int dex = 0; dex < RealShowRectItemCount; dex++)
     {
         CrateGameObject(dex);
     }
     ///2019/4/22 新增 删除多余的项
     if (ContentRectrans.childCount > RealShowRectItemCount)
     {
         for (int dex = ContentRectrans.childCount - 1; dex >= RealShowRectItemCount; dex--)
         {
             RectTransform  target     = ContentRectrans.GetChildEX(dex);
             LoopCircleItem circleItem = AllLoopCircleItems[target];
             AllLoopCircleItems.Remove(target);
             GameObject.Destroy(target.gameObject);
             if (OnItemRemoveAct != null)
             {
                 OnItemRemoveAct(target, circleItem);
             }
         }
     }
 }
 private void OnShowItem(Transform trans, LoopCircleItem loopItem)
 {
     trans.GetComponent <TestLoopCircleItem>().Show(null);
 }
 private void OnCreateItem(Transform trans, LoopCircleItem loopItem)
 {
     trans.GetAddComponent <TestLoopCircleItem>();
 }
Exemple #15
0
    private void OnShowItem(RectTransform trans, LoopCircleItem loopItem)
    {
        Debug.Log("OnShowItem __" + trans.name + "  DataIndex=" + loopItem.DataIndex);

        trans.GetComponent <TestLoopCircleItem>().Show(OnDeleteData);
    }
Exemple #16
0
 private void OnCreateItem(RectTransform trans, LoopCircleItem loopItem)
 {
     Debug.Log("OnCreateItem __" + trans.name + "  DataIndex=" + loopItem.DataIndex);
     trans.GetAddComponent <TestLoopCircleItem>();
 }
 private void OnCreateItem(Transform trans, LoopCircleItem loopItem)
 {
     Debug.Log("OnCreateItem " + trans.gameObject.name + "   " + loopItem.DataIndex);
     trans.GetAddComponent<TestLoopCircleItem>();
 }
Exemple #18
0
 private void OnDeleteItem(Transform trans, LoopCircleItem loopItem)
 {
     Debug.Log("OnDeleteItem " + trans.gameObject.name + "   " + loopItem.DataIndex);
 }