原因:
启动之后发现效果并非预设的那样,原因是因为设置成Permanent后,Viewport的rectTranform发生了变化,导致不会像预设那样实现效果
结论:
最好不要动态更改ScrollbarVisibility,若一定要更改则还要额外写死Viewport的位置
Bug过程:
ScrollView的ScrollRect组件
动态更改属性代码
public class BagPrefab : MonoBehaviour
{public ScrollRect scrollRect;void Start(){#region 调整滚动屏的属性scrollRect = GetComponentInChildren<ScrollRect>();//滚动条不消失scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.Permanent;//只能竖屏拖动scrollRect.movementType = ScrollRect.MovementType.Clamped;#endregion}}
启动前
启动后