public void DoReposition() { mNeedReposition = false; if (mChildTreeList == null) { mTotalHeight = mCachedRectTransform.rect.height; return; } mChildTreeList.Reposition(); ExpandAnimType animType = ExpandAnimateType; if (CurExpandStatus == ExpandStatus.ExpandEnd) { float itemHeight = CachedRectTransform.rect.height; mChildTreeList.CachedRectTransform.localPosition = new Vector3(ChildTreeIndent, -itemHeight, 0); float childTreeListHeight = mChildTreeList.ContentTotalHeight; mTotalHeight = mCachedRectTransform.rect.height + childTreeListHeight; mChildTreeList.CachedRectTransform.localScale = Vector3.one; mChildTreeList.CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, childTreeListHeight); } else if (CurExpandStatus == ExpandStatus.CollapseEnd) { mTotalHeight = mCachedRectTransform.rect.height; if (animType == ExpandAnimType.Immediate) { mChildTreeList.CachedRectTransform.localScale = Vector3.one; } else if (animType == ExpandAnimType.Scale) { mChildTreeList.CachedRectTransform.localScale = new Vector3(1, mMinScaleValue, 1); } else if (animType == ExpandAnimType.Clip) { mChildTreeList.CachedRectTransform.localScale = Vector3.one; mChildTreeList.CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0); } } else { float itemHeight = CachedRectTransform.rect.height; mChildTreeList.CachedRectTransform.localPosition = new Vector3(ChildTreeIndent, -itemHeight, 0); float childTreeListHeight = mChildTreeList.ContentTotalHeight * mCurExpandAnimatedValue; mTotalHeight = mCachedRectTransform.rect.height + childTreeListHeight; if (animType == ExpandAnimType.Scale) { float scaleValue = mCurExpandAnimatedValue; if (scaleValue < mMinScaleValue) { scaleValue = mMinScaleValue; } mChildTreeList.CachedRectTransform.localScale = new Vector3(1, scaleValue, 1); mChildTreeList.CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, mChildTreeList.ContentTotalHeight); } else if (animType == ExpandAnimType.Clip) { mChildTreeList.CachedRectTransform.localScale = Vector3.one; mChildTreeList.CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, childTreeListHeight); } } }
void CheckClip() { if (mChildTreeList == null) { return; } ExpandAnimType animType = ExpandAnimateType; if (animType == ExpandAnimType.Immediate) { Image img = mChildTreeList.GetComponent <Image>(); if (img != null) { Object.Destroy(img); } Mask mask = mChildTreeList.GetComponent <Mask>(); if (mask != null) { Object.Destroy(mask); } } else if (animType == ExpandAnimType.Scale) { Image img = mChildTreeList.GetComponent <Image>(); if (img != null) { Object.Destroy(img); } Mask mask = mChildTreeList.GetComponent <Mask>(); if (mask != null) { Object.Destroy(mask); } } else if (animType == ExpandAnimType.Clip) { Image img = mChildTreeList.GetComponent <Image>(); if (img == null) { img = mChildTreeList.gameObject.AddComponent <Image>(); } Mask mask = mChildTreeList.GetComponent <Mask>(); if (mask == null) { mask = mChildTreeList.gameObject.AddComponent <Mask>(); mask.showMaskGraphic = false; } } }