效果如下:
接下贴各个gameobject
接下贴各个gameobject
public Toggle _CaptureToggle;
public Toggle _RecordToggle;
public RectTransform _ParentTranform;
public LayoutElement _CaptureLayoutElement;
public LayoutElement _RecordLayoutElement;
protected ScrollSnap _ScrollSnap;
void Awake()
{
_ScrollSnap = GetComponentInChildren<ScrollSnap>();
TimerManager.Instance.StartCoroutine(WaitForSetLayout());
}
//初始化并定位每个gameobject的中心位置
IEnumerator WaitForSetLayout()
{
//yield return new WaitForSeconds(0.5f);
yield return new WaitForEndOfFrame();
if (_ParentTranform.rect.width != _CaptureLayoutElement.preferredWidth ||
_ParentTranform.rect.height != _CaptureLayoutElement.preferredHeight)
{
gameObject.SetActive(false);
if (_CaptureLayoutElement.gameObject)
{
_CaptureLayoutElement.preferredWidth = _ParentTranform.rect.width;
_CaptureLayoutElement.preferredHeight = _ParentTranform.rect.height;
}
if (_RecordLayoutElement.gameObject)
{
_RecordLayoutElement.preferredWidth