昨天因为有个滚动列表需要纵向自适应的需求,发现了项目底层滚动组件的bug。底层滚动组件可视区域的尺寸取值用的是sizeDelta,其实在此之前我也一直有这样的误解,认为sizeDelta就是实际尺寸,但其实不然,实际尺寸是rect.size。查阅
Unity官方文档,发现:
The size of this RectTransform relative to the distances between the anchors.
If the anchors are together, sizeDelta is the same as size. If the anchors are in each of the four corners of the parent, the sizeDelta is how much bigger or smaller the rectangle is compared to its parent.
sizeDelta与锚点之间的的距离有关!
如果四个锚点分布在一起时,sizeDelta = Rect.size。
如果锚点分布在parent的四个角时&#