Text Lbl = gameObject.GetComponent<Text>();
RectTransform RT = gameObject.GetComponent<RectTransform>();
RT.sizeDelta = new Vector2(RT.sizeDelta.x,RT.sizeDelya.y + Lbl.preferredHeight);
Unity背景自适应文字高度
最新推荐文章于 2025-08-12 16:25:59 发布
本文介绍了一种在 Unity 中实现 UI 自适应布局的方法。通过调整 RectTransform 的 sizeDelta 属性来适应不同分辨率的屏幕,确保 Text 组件能够正确显示。
2万+

被折叠的 条评论
为什么被折叠?



