Unity3d 更改布局组childForceExpand的代码

Unity3d 更改布局组childForceExpand的代码,unity3d,unityscript,Unity3d,Unityscript,我只是想知道如何使用代码访问布局组的childForceExpand。我正在将垂直布局组附加到实例化的面板,并希望禁用“强制展开”。类似于: using UnityEngine.UI; VerticalLayoutGroup grp = GetComponent<VerticalLayoutGroup>(); grp.childForceExpandHeight = true; grp.childForceExpandWidth = false; 使用UnityE

我只是想知道如何使用代码访问布局组的
childForceExpand
。我正在将垂直布局组附加到实例化的面板,并希望禁用“强制展开”。

类似于:

  using UnityEngine.UI;

  VerticalLayoutGroup grp = GetComponent<VerticalLayoutGroup>();
  grp.childForceExpandHeight = true;
  grp.childForceExpandWidth = false;
使用UnityEngine.UI;
VerticalLayoutGroup grp=GetComponent();
grp.childForceExpandHeight=真;
grp.childForceExpandWidth=false;

你能提供一个代码示例吗?我可以发誓我昨晚试过了,但出现了一个错误,一定是拼错了,没有注意到,谢谢