예제 #1
0
        /// <summary>
        /// Gets the height of the item.
        /// </summary>
        /// <returns>The item height.</returns>
        /// <param name="item">Item.</param>
        float CalculateItemHeight(TItem item)
        {
            if (defaultItemLayoutGroup == null)
            {
                DefaultItemCopy.gameObject.SetActive(true);

                defaultItemLayoutGroup = DefaultItemCopy.GetComponent <LayoutGroup>();
            }

            float height = 0f;

            if (!IsCanCalculateHeight || ForceAutoHeightCalculation)
            {
                if (defaultItemLayoutGroup != null)
                {
                    SetData(DefaultItemCopy, item);

                    var lg = DefaultItemCopy.GetComponentsInChildren <LayoutGroup>();
                    Array.Reverse(lg);
                    lg.ForEach(LayoutUtilites.UpdateLayout);

                    LayoutUtilites.UpdateLayout(defaultItemLayoutGroup);

                    height = LayoutUtility.GetPreferredHeight(DefaultItemCopyRect);
                }
            }
            else
            {
                SetData(DefaultItemCopy, item);

                height = (DefaultItemCopy as IListViewItemHeight).Height;
            }

            return(height);
        }
예제 #2
0
        Vector2 CalculateComponentSize(TItem item)
        {
            if (defaultItemLayoutGroup == null)
            {
                return(Vector2.zero);
            }

            SetData(DefaultItemCopy, item);

            var lg = DefaultItemCopy.GetComponentsInChildren <LayoutGroup>();

            Array.Reverse(lg);
            lg.ForEach(LayoutUtilites.UpdateLayout);

            LayoutUtilites.UpdateLayout(defaultItemLayoutGroup);

            var size = new Vector2(
                LayoutUtility.GetPreferredWidth(DefaultItemCopyRect),
                LayoutUtility.GetPreferredHeight(DefaultItemCopyRect)
                );

            return(size);
        }
예제 #3
0
        /// <summary>
        /// Gets the width of the item.
        /// </summary>
        /// <returns>The item width.</returns>
        /// <param name="item">Item.</param>
        float CalculateItemWidth(TItem item)
        {
            if (defaultItemLayoutGroup == null)
            {
                defaultItemLayoutGroup = DefaultItemCopy.GetComponent <LayoutGroup>();
            }

            float width = 0f;

            if (!IsCanCalculateWidth || ForceAutoWidthCalculation)
            {
                if (defaultItemLayoutGroup != null)
                {
                    DefaultItemCopy.gameObject.SetActive(true);

                    SetData(DefaultItemCopy, item);

                    var lg = DefaultItemCopy.GetComponentsInChildren <LayoutGroup>();
                    Array.Reverse(lg);
                    lg.ForEach(LayoutUtilites.UpdateLayout);

                    LayoutUtilites.UpdateLayout(defaultItemLayoutGroup);

                    width = LayoutUtility.GetPreferredWidth(DefaultItemCopyRect);

                    DefaultItemCopy.gameObject.SetActive(false);
                }
            }
            else
            {
                SetData(DefaultItemCopy, item);

                width = (DefaultItemCopy as IListViewItemWidth).Width;
            }

            return(width);
        }