예제 #1
0
        /// <summary>
        /// 渲染一个 Data
        /// </summary>
        /// <param name="data"></param>
        private void RenderItem(DYData data)
        {
            DYDataGridItem item = GetDYDataGridItemByPrefabPath(data.prefabPath);

            item.rectTrans.SetParent(this.content);
            item.rectTrans.anchoredPosition3D = data.itemPos;
            item.rectTrans.localScale         = Vector3.one;

            item.data = data;
            item.Render();

            activeDataGridItem.Add(data, item);
        }
예제 #2
0
        /// <summary>
        /// 回收一个 Data Item
        /// </summary>
        /// <param name="data"></param>
        private void RecoupItem(DYData data)
        {
            DYDataGridItem item = null;

            activeDataGridItem.TryGetValue(data, out item);

            if (item != null)
            {
                activeDataGridItem.Remove(data);
                item.Release();
                CacheDYDataGridItem(data.prefabPath, item);
            }
            else
            {
                Debug.LogError("回收数据出错,无法在活动的 Data 中找到对应的 Item ");
            }
        }
예제 #3
0
        /// <summary>
        /// 判断一个Data是否在content的渲染范围内
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        private bool IsNeedRender(DYData data)
        {
            bool result = false;

            if (scrollDir == enScrollDir.Horizontal)
            {
                if (data.itemPos.x >= contentRenderLeftTop.x && data.itemPos.x <= contentRenderRightBottom.x)
                {
                    result = true;
                }
            }
            else
            {
                if ((data.itemPos.y <= contentRenderLeftTop.y || (data.itemPos.y - data.dyDataGridSize.y) <= contentRenderLeftTop.y) &&
                    (data.itemPos.y > contentRenderRightBottom.y || (data.itemPos.y - data.dyDataGridSize.y) >= contentRenderRightBottom.y))
                {
                    result = true;
                }
            }

            return(result);
        }