public void SetCallBackFunction(GameObject handle, string fun) { foreach (UICollapsibleListItemCtrlBase o in itemList) { UICollapsibleListItemCtrlBase itemCtrl = o.GetComponent <UICollapsibleListItemCtrlBase>(); if (itemCtrl != null) { itemCtrl.SetCallback(handle, fun); } } }
// Update is called once per frame void Update() { if (collapsingItemIndex >= 0) { UICollapsibleListItemCtrlBase ctrl = itemList[collapsingItemIndex]; float deltaTime = 0.04f; if (Time.deltaTime < 0.04f) { deltaTime = Time.deltaTime; } collapsingTimer += deltaTime; //伸缩 float scale = 1f; if (collapsingTimer < collapsingTime) { scale = collapsingTimer / collapsingTime; } if (isCollapsing) { scale = 1 - scale; } ctrl.content.localScale = new Vector3(1, scale, 1); ctrl.curContentHeight = scale * ctrl.contentHeight; //重新计算位置 CalculateItemPos(collapsingItemIndex + 1, -1); //是否折叠完成 if (collapsingTimer >= collapsingTime) { if (isCollapsing) { ctrl.content.gameObject.SetActive(false); //隐藏起来 } isCollapsing = false; isExpanding = false; collapsingItemIndex = -1; if (callBack != null) { callBack(); } } } }