[Unity]Scroll View的Content不能完全显示子UI的问题解决办法

版权声明:本博客一本正经胡说八道,文章内容不能作参考。本文为博主原创文章,未经博主允许不得转载。该博客所用图片资源均作学习分享用途,仅供参考,请勿用于商业行为。传播者自负。 如果本博客所写文章侵犯到您的权益,请主动联系留言,我们将及时删除相关内容。 https://blog.csdn.net/BuladeMian/article/details/90340608

Scroll View在Inspector视图的内容。

Scroll View

-Viewport

--Content

---UI Image

---UI Image 1

---UI Image 2

-Scrollbar Horizontal

-Scrollbar Vertiacl


Scroll View的Content不能完全显示子UI 

的解决办法。

调整Content的 RectTransform组件的Height。(当Content的ContentSizeFitter组件的 Vertical Fit 设置无效果的时候,也可以用下面的代码。)


            float height = UIimage.GetComponent<RectTransform>().sizeDelta.y;//t为子UI(UI Image)
            height = height * i;//i是显示子UI(UI Image)的 数量
            Vector2 vector2 = Panel_content.GetComponent<RectTransform>().sizeDelta;
            Panel_content.GetComponent<RectTransform>().sizeDelta = new Vector2(vector2.x, height);//仅仅改变 Content的 RectTransform组件的Height即可。

Scroll View的Scrollbar Vertiacl垂直滑条 不能完全 显示 子UI 的解决办法。

Scrollbar Vertiacl有一个Scrollbar组件,调整Scrollbar组件的Size大小即可。


参考资料:

1.Unity4.6中修改RectTransform的宽度和高度

2.

3.

猜你喜欢

转载自blog.csdn.net/BuladeMian/article/details/90340608
今日推荐