private void refreshContentSizeFitters()
{
// 获取 contentParent 下的所有 ContentSizeFitter 组件
ContentSizeFitter[] contentSizeFitters = gameObject.GetComponentsInChildren<ContentSizeFitter>();
for (int i = 0; i < contentSizeFitters.Length; i++)
{
LayoutRebuilder.ForceRebuildLayoutImmediate(contentSizeFitters[i].GetComponent<RectTransform>());
}
VerticalLayoutGroup[] verticalLayouts = gameObject.GetComponentsInChildren<VerticalLayoutGroup>();
for (int i = 0; i < verticalLayouts.Length; i++)
{
LayoutRebuilder.ForceRebuildLayoutImmediate(verticalLayouts[i].GetComponent<RectTransform>());
}
HorizontalLayoutGroup[] horizontalLayouts = gameObject.GetComponentsInChildren<HorizontalLayoutGroup>();
for (int i = 0; i < horizontalLayouts.Length; i++)
{
LayoutRebuilder.ForceRebuildLayoutImmediate(horizontalLayouts[i].GetComponent<RectTransform>());
}
}
Unity 刷新文本
原创DaLiangChen 博主文章分类:Unity ©著作权
文章标签 java 前端 javascript i++ 文章分类 JavaScript 前端开发
下一篇:Unity闪屏Logo去除
-
Vue 强制刷新文档流
强制刷新页面文档流的方式
vue.js 前端 javascript 强制刷新 活动状态