protected override void ProcessElements() { this.m_contentSize = Vector2.zero; Vector2 zero = Vector2.zero; if (this.m_listType == enUIListType.Horizontal) { zero.x += this.m_elementLayoutOffset; } else if (this.m_listType == enUIListType.Vertical) { zero.y += this.m_elementLayoutOffset; } for (int i = 0; i < this.m_elementAmount; i++) { stRect stRect = base.LayoutElement(i, ref this.m_contentSize, ref zero); if (i < this.m_elementsRect.get_Count()) { this.m_elementsRect.set_Item(i, stRect); } else { this.m_elementsRect.Add(stRect); } if (!this.m_useOptimized || base.IsRectInScrollArea(ref stRect)) { base.CreateElement(i, ref stRect); } } this.ResizeContent(ref this.m_contentSize, false); }
protected override void ProcessElements() { base.m_contentSize = Vector2.zero; Vector2 zero = Vector2.zero; if (base.m_listType == enUIListType.Horizontal) { zero.x += base.m_elementLayoutOffset; } else if (base.m_listType == enUIListType.Vertical) { zero.y += base.m_elementLayoutOffset; } for (int i = 0; i < base.m_elementAmount; i++) { stRect item = base.LayoutElement(i, ref this.m_contentSize, ref zero); if (i < base.m_elementsRect.Count) { base.m_elementsRect[i] = item; } else { base.m_elementsRect.Add(item); } if (!base.m_useOptimized || base.IsRectInScrollArea(ref item)) { base.CreateElement(i, ref item); } } this.ResizeContent(ref this.m_contentSize, false); }
protected override void ProcessElements() { this.m_contentSize = Vector2.zero; Vector2 zero = Vector2.zero; this.m_contentSize.x = this.m_contentSize.x + this.m_contentExtendSize; zero.x += this.m_contentExtendSize; for (int i = 0; i < this.m_elementAmount; i++) { stRect stRect = base.LayoutElement(i, ref this.m_contentSize, ref zero); if (i < this.m_elementsRect.get_Count()) { this.m_elementsRect.set_Item(i, stRect); } else { this.m_elementsRect.Add(stRect); } if (!this.m_useOptimized || base.IsRectInScrollArea(ref stRect)) { CUIListElementScript cUIListElementScript = base.CreateElement(i, ref stRect); } } this.m_contentSize.x = this.m_contentSize.x + this.m_contentExtendSize; this.ResizeContent(ref this.m_contentSize, false); }
private bool IsElementInSelectedArea(int index) { stRect rect = base.m_elementsRect[index]; float num = rect.m_center.x + base.m_contentRectTransform.anchoredPosition.x; return((num > this.m_selectAreaMin) && (num < this.m_selectAreaMax)); }
protected override void ProcessElements() { base.m_contentSize = Vector2.zero; Vector2 zero = Vector2.zero; this.m_contentSize.x += this.m_contentExtendSize; zero.x += this.m_contentExtendSize; for (int i = 0; i < base.m_elementAmount; i++) { stRect item = base.LayoutElement(i, ref this.m_contentSize, ref zero); if (i < base.m_elementsRect.Count) { base.m_elementsRect[i] = item; } else { base.m_elementsRect.Add(item); } if (!base.m_useOptimized || base.IsRectInScrollArea(ref item)) { CUIListElementScript script = base.CreateElement(i, ref item); if (script != null) { RectTransform transform = script.gameObject.transform as RectTransform; transform.pivot = new Vector2(0.5f, 0.5f); transform.anchoredPosition = item.m_center; } } } this.m_contentSize.x += this.m_contentExtendSize; this.ResizeContent(ref this.m_contentSize, false); }
protected override void ProcessElements() { base.m_contentSize = Vector2.zero; Vector2 zero = Vector2.zero; this.m_contentSize.x += this.m_contentExtendSize; zero.x += this.m_contentExtendSize; for (int i = 0; i < base.m_elementAmount; i++) { stRect item = base.LayoutElement(i, ref this.m_contentSize, ref zero); if (i < base.m_elementsRect.Count) { base.m_elementsRect[i] = item; } else { base.m_elementsRect.Add(item); } if (!base.m_useOptimized || base.IsRectInScrollArea(ref item)) { CUIListElementScript script = base.CreateElement(i, ref item); } } this.m_contentSize.x += this.m_contentExtendSize; this.ResizeContent(ref this.m_contentSize, false); }
protected bool IsRectInScrollArea(ref stRect rect) { Vector2 zero = Vector2.zero; zero.x = this.m_contentRectTransform.anchoredPosition.x + rect.m_left; zero.y = this.m_contentRectTransform.anchoredPosition.y + rect.m_top; return((((zero.x + rect.m_width) >= 0f) && (zero.x <= this.m_scrollAreaSize.x)) && (((zero.y - rect.m_height) <= 0f) && (zero.y >= -this.m_scrollAreaSize.y))); }
public void SetRect(ref stRect rect) { this.m_rect = rect; RectTransform transform = base.gameObject.transform as RectTransform; transform.sizeDelta = new Vector2((float)this.m_rect.m_width, (float)this.m_rect.m_height); transform.anchoredPosition = new Vector2((float)rect.m_left, (float)rect.m_top); }
protected bool IsRectInScrollArea(ref stRect rect) { Vector2 zero = Vector2.zero; zero.x = this.m_contentRectTransform.anchoredPosition.x + (float)rect.m_left; zero.y = this.m_contentRectTransform.anchoredPosition.y + (float)rect.m_top; return(zero.x + (float)rect.m_width >= 0f && zero.x <= this.m_scrollAreaSize.x && zero.y - (float)rect.m_height <= 0f && zero.y >= -this.m_scrollAreaSize.y); }
public bool IsElementInScrollArea(int index) { if ((index < 0) || (index >= this.m_elementAmount)) { return(false); } stRect rect = !this.m_useOptimized ? this.m_elementScripts[index].m_rect : this.m_elementsRect[index]; return(this.IsRectInScrollArea(ref rect)); }
public bool IsElementInScrollArea(int index) { if (index < 0 || index >= this.m_elementAmount) { return(false); } stRect stRect = this.m_useOptimized ? this.m_elementsRect.get_Item(index) : this.m_elementScripts[index].m_rect; return(this.IsRectInScrollArea(ref stRect)); }
private float GetElementScale(int index) { stRect rect = base.m_elementsRect[index]; int num = (int)(rect.m_center.x + base.m_contentRectTransform.anchoredPosition.x); int num2 = (int)Mathf.Abs((float)(num - this.m_stepListCenter)); int num3 = num2 / ((int)this.m_elementDefaultSize.x); int num4 = num2 % ((int)this.m_elementDefaultSize.x); float num5 = Mathf.Pow(this.m_reductionRate, (float)num3); float num6 = Mathf.Pow(this.m_reductionRate, (float)(num3 + 1)); return(num5 - ((num5 - num6) * (((float)num4) / this.m_elementDefaultSize.x))); }
protected stRect LayoutElement(int index, ref Vector2 contentSize, ref Vector2 offset) { stRect rect; rect = new stRect { m_width = (((this.m_elementsSize != null) && (this.m_listType != enUIListType.Vertical)) && ((this.m_listType != enUIListType.VerticalGrid) && (this.m_listType != enUIListType.HorizontalGrid))) ? ((int)this.m_elementsSize[index].x) : ((int)this.m_elementDefaultSize.x), m_height = (((this.m_elementsSize != null) && (this.m_listType != enUIListType.Horizontal)) && ((this.m_listType != enUIListType.VerticalGrid) && (this.m_listType != enUIListType.HorizontalGrid))) ? ((int)this.m_elementsSize[index].y) : ((int)this.m_elementDefaultSize.y), m_left = (int)offset.x, m_top = (int)offset.y, m_right = rect.m_left + rect.m_width, m_bottom = rect.m_top - rect.m_height, m_center = new Vector2(rect.m_left + (rect.m_width * 0.5f), rect.m_top - (rect.m_height * 0.5f)) }; if (rect.m_right > contentSize.x) { contentSize.x = rect.m_right; } if (-rect.m_bottom > contentSize.y) { contentSize.y = -rect.m_bottom; } switch (this.m_listType) { case enUIListType.Vertical: offset.y -= rect.m_height + this.m_elementSpacing.y; return(rect); case enUIListType.Horizontal: offset.x += rect.m_width + this.m_elementSpacing.x; return(rect); case enUIListType.VerticalGrid: offset.x += rect.m_width + this.m_elementSpacing.x; if ((offset.x + rect.m_width) > this.m_scrollAreaSize.x) { offset.x = 0f; offset.y -= rect.m_height + this.m_elementSpacing.y; } return(rect); case enUIListType.HorizontalGrid: offset.y -= rect.m_height + this.m_elementSpacing.y; if ((-offset.y + rect.m_height) > this.m_scrollAreaSize.y) { offset.y = 0f; offset.x += rect.m_width + this.m_elementSpacing.x; } return(rect); } return(rect); }
public void SelectElementImmediately(int index) { base.SelectElement(index, true); base.m_contentSize = Vector2.zero; Vector2 zero = Vector2.zero; if (base.m_listType == enUIListType.Horizontal) { zero.x += base.m_elementLayoutOffset; } else if (base.m_listType == enUIListType.Vertical) { zero.y += base.m_elementLayoutOffset; } for (int i = 0; i < base.m_elementAmount; i++) { stRect item = this.LayoutExpandElement(i, (i != index) ? ((float)0) : ((float)1), ref this.m_contentSize, ref zero); if (i < base.m_elementsRect.Count) { base.m_elementsRect[i] = item; } else { base.m_elementsRect.Add(item); } } this.ResizeContent(ref this.m_contentSize, false); if ((index < 0) || (index >= base.m_elementAmount)) { base.m_contentRectTransform.anchoredPosition = Vector2.zero; } else { base.m_contentRectTransform.anchoredPosition = this.GetTargetContentAnchoredPosition(index); } for (int j = 0; j < base.m_elementAmount; j++) { stRect rect = base.m_elementsRect[j]; CUIListElementScript elemenet = base.GetElemenet(j); if (elemenet != null) { elemenet.SetRect(ref rect); } else if (!base.m_useOptimized || base.IsRectInScrollArea(ref rect)) { base.CreateElement(j, ref rect); } } }
public void SelectElementImmediately(int index) { base.SelectElement(index, true); this.m_contentSize = Vector2.zero; Vector2 zero = Vector2.zero; if (this.m_listType == enUIListType.Horizontal) { zero.x += this.m_elementLayoutOffset; } else if (this.m_listType == enUIListType.Vertical) { zero.y += this.m_elementLayoutOffset; } for (int i = 0; i < this.m_elementAmount; i++) { stRect stRect = this.LayoutExpandElement(i, (float)((i != index) ? 0 : 1), ref this.m_contentSize, ref zero); if (i < this.m_elementsRect.get_Count()) { this.m_elementsRect.set_Item(i, stRect); } else { this.m_elementsRect.Add(stRect); } } this.ResizeContent(ref this.m_contentSize, false); if (index < 0 || index >= this.m_elementAmount) { this.m_contentRectTransform.anchoredPosition = Vector2.zero; } else { this.m_contentRectTransform.anchoredPosition = this.GetTargetContentAnchoredPosition(index); } for (int j = 0; j < this.m_elementAmount; j++) { stRect stRect2 = this.m_elementsRect.get_Item(j); CUIListElementScript elemenet = base.GetElemenet(j); if (elemenet != null) { elemenet.SetRect(ref stRect2); } else if (!this.m_useOptimized || base.IsRectInScrollArea(ref stRect2)) { base.CreateElement(j, ref stRect2); } } }
protected stRect LayoutElement(int index, ref Vector2 contentSize, ref Vector2 offset) { stRect result = default(stRect); result.m_width = (int)((this.m_elementsSize == null || this.m_listType == enUIListType.Vertical || this.m_listType == enUIListType.VerticalGrid || this.m_listType == enUIListType.HorizontalGrid) ? this.m_elementDefaultSize.x : this.m_elementsSize.get_Item(index).x); result.m_height = (int)((this.m_elementsSize == null || this.m_listType == enUIListType.Horizontal || this.m_listType == enUIListType.VerticalGrid || this.m_listType == enUIListType.HorizontalGrid) ? this.m_elementDefaultSize.y : this.m_elementsSize.get_Item(index).y); result.m_left = (int)offset.x; result.m_top = (int)offset.y; result.m_right = result.m_left + result.m_width; result.m_bottom = result.m_top - result.m_height; result.m_center = new Vector2((float)result.m_left + (float)result.m_width * 0.5f, (float)result.m_top - (float)result.m_height * 0.5f); if ((float)result.m_right > contentSize.x) { contentSize.x = (float)result.m_right; } if (-(float)result.m_bottom > contentSize.y) { contentSize.y = -(float)result.m_bottom; } switch (this.m_listType) { case enUIListType.Vertical: offset.y -= (float)result.m_height + this.m_elementSpacing.y; break; case enUIListType.Horizontal: offset.x += (float)result.m_width + this.m_elementSpacing.x; break; case enUIListType.VerticalGrid: offset.x += (float)result.m_width + this.m_elementSpacing.x; if (offset.x + (float)result.m_width > this.m_scrollAreaSize.x) { offset.x = 0f; offset.y -= (float)result.m_height + this.m_elementSpacing.y; } break; case enUIListType.HorizontalGrid: offset.y -= (float)result.m_height + this.m_elementSpacing.y; if (-offset.y + (float)result.m_height > this.m_scrollAreaSize.y) { offset.y = 0f; offset.x += (float)result.m_width + this.m_elementSpacing.x; } break; } return(result); }
public void SetRect(ref stRect rect) { this.m_rect = rect; RectTransform transform = base.gameObject.transform as RectTransform; transform.sizeDelta = new Vector2((float)this.m_rect.m_width, (float)this.m_rect.m_height); if (this.m_pivotType == enPivotType.Centre) { transform.anchoredPosition = rect.m_center; } else { transform.anchoredPosition = new Vector2((float)rect.m_left, (float)rect.m_top); } }
protected virtual void ProcessElements() { this.m_contentSize = Vector2.zero; Vector2 zero = Vector2.zero; if (this.m_listType == enUIListType.Vertical || this.m_listType == enUIListType.VerticalGrid) { zero.y += this.m_elementLayoutOffset; } else { zero.x += this.m_elementLayoutOffset; } for (int i = 0; i < this.m_elementAmount; i++) { stRect stRect = this.LayoutElement(i, ref this.m_contentSize, ref zero); if (this.m_useOptimized) { if (i < this.m_elementsRect.get_Count()) { this.m_elementsRect.set_Item(i, stRect); } else { this.m_elementsRect.Add(stRect); } } if (!this.m_useOptimized || this.IsRectInScrollArea(ref stRect)) { this.CreateElement(i, ref stRect); } } if (this.m_extraContent != null) { if (this.m_elementAmount > 0 && this.m_isExtraContentEnabled) { this.ProcessExtraContent(ref this.m_contentSize, zero); } else { this.m_extraContent.CustomSetActive(false); } } this.ResizeContent(ref this.m_contentSize, false); }
private float GetContentTargetPosition(int selectedIndex) { if ((selectedIndex < 0) || (selectedIndex >= base.m_elementAmount)) { return(0f); } stRect rect = base.m_elementsRect[selectedIndex]; float num = this.m_stepListCenter - rect.m_center.x; if (num > 0f) { return(0f); } if (num < (this.m_scrollAreaSize.x - this.m_contentSize.x)) { num = this.m_scrollAreaSize.x - this.m_contentSize.x; } return(num); }
public void Enable(CUIListScript belongedList, int index, string name, ref stRect rect, bool selected) { base.m_belongedListScript = belongedList; this.m_index = index; base.gameObject.name = name + "_" + index.ToString(); if (this.m_useSetActiveForDisplay) { base.gameObject.CustomSetActive(true); } else { this.m_canvasGroup.alpha = 1f; this.m_canvasGroup.blocksRaycasts = true; } this.SetComponentBelongedList(base.gameObject); this.SetRect(ref rect); this.ChangeDisplay(selected); this.DispatchOnEnableEvent(); }
public void MoveElementInScrollArea(int index, bool moveImmediately) { if (index < 0 || index >= this.m_elementAmount) { return; } Vector2 zero = Vector2.zero; Vector2 zero2 = Vector2.zero; stRect stRect = this.m_useOptimized ? this.m_elementsRect.get_Item(index) : this.m_elementScripts[index].m_rect; zero2.x = this.m_contentRectTransform.anchoredPosition.x + (float)stRect.m_left; zero2.y = this.m_contentRectTransform.anchoredPosition.y + (float)stRect.m_top; if (zero2.x < 0f) { zero.x = -zero2.x; } else if (zero2.x + (float)stRect.m_width > this.m_scrollAreaSize.x) { zero.x = this.m_scrollAreaSize.x - (zero2.x + (float)stRect.m_width); } if (zero2.y > 0f) { zero.y = -zero2.y; } else if (zero2.y - (float)stRect.m_height < -this.m_scrollAreaSize.y) { zero.y = -this.m_scrollAreaSize.y - (zero2.y - (float)stRect.m_height); } if (moveImmediately) { this.m_contentRectTransform.anchoredPosition += zero; } else { Vector2 to = this.m_contentRectTransform.anchoredPosition + zero; LeanTween.value(base.gameObject, delegate(Vector2 pos) { this.m_contentRectTransform.anchoredPosition = pos; }, this.m_contentRectTransform.anchoredPosition, to, this.m_fSpeed); } }
private Vector2 GetTargetContentAnchoredPosition(int selectedElementIndex) { if ((selectedElementIndex < 0) || (selectedElementIndex >= base.m_elementAmount)) { return(this.m_contentAnchoredPosition); } stRect rect = base.m_elementsRect[base.m_selectedElementIndex]; rect.m_width = (int)this.m_elementExpandedSize.x; rect.m_height = (int)this.m_elementExpandedSize.y; rect.m_right = rect.m_left + rect.m_width; rect.m_bottom = rect.m_top - rect.m_height; Vector2 contentAnchoredPosition = this.m_contentAnchoredPosition; if (base.m_listType == enUIListType.Horizontal) { if ((contentAnchoredPosition.x + rect.m_right) > this.m_scrollAreaSize.x) { contentAnchoredPosition.x = this.m_scrollAreaSize.x - rect.m_right; } if ((contentAnchoredPosition.x + rect.m_left) < 0f) { contentAnchoredPosition.x = -rect.m_left; } return(contentAnchoredPosition); } if (base.m_listType == enUIListType.Vertical) { if ((contentAnchoredPosition.y + rect.m_bottom) < -this.m_scrollAreaSize.y) { contentAnchoredPosition.y = -this.m_scrollAreaSize.y - rect.m_bottom; } if ((contentAnchoredPosition.y + rect.m_top) > 0f) { contentAnchoredPosition.y = -rect.m_top; } } return(contentAnchoredPosition); }
private Vector2 GetTargetContentAnchoredPosition(int selectedElementIndex) { if (selectedElementIndex < 0 || selectedElementIndex >= this.m_elementAmount) { return(this.m_contentAnchoredPosition); } stRect stRect = this.m_elementsRect.get_Item(this.m_selectedElementIndex); stRect.m_width = (int)this.m_elementExpandedSize.x; stRect.m_height = (int)this.m_elementExpandedSize.y; stRect.m_right = stRect.m_left + stRect.m_width; stRect.m_bottom = stRect.m_top - stRect.m_height; Vector2 contentAnchoredPosition = this.m_contentAnchoredPosition; if (this.m_listType == enUIListType.Horizontal) { if (contentAnchoredPosition.x + (float)stRect.m_right > this.m_scrollAreaSize.x) { contentAnchoredPosition.x = this.m_scrollAreaSize.x - (float)stRect.m_right; } if (contentAnchoredPosition.x + (float)stRect.m_left < 0f) { contentAnchoredPosition.x = (float)(-(float)stRect.m_left); } } else if (this.m_listType == enUIListType.Vertical) { if (contentAnchoredPosition.y + (float)stRect.m_bottom < -this.m_scrollAreaSize.y) { contentAnchoredPosition.y = -this.m_scrollAreaSize.y - (float)stRect.m_bottom; } if (contentAnchoredPosition.y + (float)stRect.m_top > 0f) { contentAnchoredPosition.y = (float)(-(float)stRect.m_top); } } return(contentAnchoredPosition); }
private stRect LayoutExpandElement(int index, float expandedRate, ref Vector2 contentSize, ref Vector2 offset) { stRect rect = new stRect(); if (base.m_listType == enUIListType.Horizontal) { rect.m_width = (int)(this.m_elementDefaultSize.x + ((this.m_elementExpandedSize.x - this.m_elementDefaultSize.x) * expandedRate)); rect.m_height = (int)this.m_elementDefaultSize.y; } else { rect.m_width = (int)this.m_elementDefaultSize.x; rect.m_height = (int)(this.m_elementDefaultSize.y + ((this.m_elementExpandedSize.y - this.m_elementDefaultSize.y) * expandedRate)); } rect.m_left = (int)offset.x; rect.m_top = (int)offset.y; rect.m_right = rect.m_left + rect.m_width; rect.m_bottom = rect.m_top - rect.m_height; rect.m_center = new Vector2(rect.m_left + (rect.m_width * 0.5f), rect.m_top - (rect.m_height * 0.5f)); if (rect.m_right > contentSize.x) { contentSize.x = rect.m_right; } if (-rect.m_bottom > contentSize.y) { contentSize.y = -rect.m_bottom; } if (base.m_listType == enUIListType.Horizontal) { offset.x += rect.m_width + this.m_elementSpacing.x; return(rect); } if (base.m_listType == enUIListType.Vertical) { offset.y -= rect.m_height + this.m_elementSpacing.y; } return(rect); }
private stRect LayoutExpandElement(int index, float expandedRate, ref Vector2 contentSize, ref Vector2 offset) { stRect result = default(stRect); if (this.m_listType == enUIListType.Horizontal) { result.m_width = (int)(this.m_elementDefaultSize.x + (this.m_elementExpandedSize.x - this.m_elementDefaultSize.x) * expandedRate); result.m_height = (int)this.m_elementDefaultSize.y; } else { result.m_width = (int)this.m_elementDefaultSize.x; result.m_height = (int)(this.m_elementDefaultSize.y + (this.m_elementExpandedSize.y - this.m_elementDefaultSize.y) * expandedRate); } result.m_left = (int)offset.x; result.m_top = (int)offset.y; result.m_right = result.m_left + result.m_width; result.m_bottom = result.m_top - result.m_height; result.m_center = new Vector2((float)result.m_left + (float)result.m_width * 0.5f, (float)result.m_top - (float)result.m_height * 0.5f); if ((float)result.m_right > contentSize.x) { contentSize.x = (float)result.m_right; } if ((float)(-(float)result.m_bottom) > contentSize.y) { contentSize.y = (float)(-(float)result.m_bottom); } if (this.m_listType == enUIListType.Horizontal) { offset.x += (float)result.m_width + this.m_elementSpacing.x; } else if (this.m_listType == enUIListType.Vertical) { offset.y -= (float)result.m_height + this.m_elementSpacing.y; } return(result); }
protected CUIListElementScript CreateElement(int index, ref stRect rect) { CUIListElementScript cUIListElementScript = null; if (this.m_unUsedElementScripts.Count > 0) { cUIListElementScript = this.m_unUsedElementScripts[0]; this.m_unUsedElementScripts.RemoveAt(0); } else if (this.m_elementTemplate != null) { GameObject gameObject = base.Instantiate(this.m_elementTemplate); gameObject.transform.SetParent(this.m_content.transform); gameObject.transform.localScale = Vector3.one; base.InitializeComponent(gameObject); cUIListElementScript = gameObject.GetComponent <CUIListElementScript>(); } if (cUIListElementScript != null) { cUIListElementScript.Enable(this, index, this.m_elementName, ref rect, this.IsSelectedIndex(index)); this.m_elementScripts.Add(cUIListElementScript); } return(cUIListElementScript); }
public void MoveElementInScrollArea(int index, bool moveImmediately) { if ((index >= 0) && (index < this.m_elementAmount)) { Vector2 zero = Vector2.zero; Vector2 vector2 = Vector2.zero; stRect rect = !this.m_useOptimized ? this.m_elementScripts[index].m_rect : this.m_elementsRect[index]; vector2.x = this.m_contentRectTransform.anchoredPosition.x + rect.m_left; vector2.y = this.m_contentRectTransform.anchoredPosition.y + rect.m_top; if (vector2.x < 0f) { zero.x = -vector2.x; } else if ((vector2.x + rect.m_width) > this.m_scrollAreaSize.x) { zero.x = this.m_scrollAreaSize.x - (vector2.x + rect.m_width); } if (vector2.y > 0f) { zero.y = -vector2.y; } else if ((vector2.y - rect.m_height) < -this.m_scrollAreaSize.y) { zero.y = -this.m_scrollAreaSize.y - (vector2.y - rect.m_height); } if (moveImmediately) { this.m_contentRectTransform.anchoredPosition += zero; } else { Vector2 to = this.m_contentRectTransform.anchoredPosition + zero; LeanTween.value(base.gameObject, pos => this.m_contentRectTransform.anchoredPosition = pos, this.m_contentRectTransform.anchoredPosition, to, this.m_fSpeed); } } }
protected void UpdateElementsScroll() { int i = 0; while (i < this.m_elementScripts.Count) { if (!this.IsRectInScrollArea(ref this.m_elementScripts[i].m_rect)) { this.RecycleElement(this.m_elementScripts[i], true); } else { i++; } } for (int j = 0; j < this.m_elementAmount; j++) { stRect stRect = this.m_elementsRect.get_Item(j); if (this.IsRectInScrollArea(ref stRect)) { bool flag = false; for (int k = 0; k < this.m_elementScripts.Count; k++) { if (this.m_elementScripts[k].m_index == j) { flag = true; break; } } if (!flag) { this.CreateElement(j, ref stRect); } } } }
protected void UpdateElementsScroll() { int num = 0; while (num < this.m_elementScripts.Count) { if (!this.IsRectInScrollArea(ref this.m_elementScripts[num].m_rect)) { this.RecycleElement(this.m_elementScripts[num], true); } else { num++; } } for (int i = 0; i < this.m_elementAmount; i++) { stRect rect = this.m_elementsRect[i]; if (this.IsRectInScrollArea(ref rect)) { bool flag = false; for (int j = 0; j < this.m_elementScripts.Count; j++) { if (this.m_elementScripts[j].m_index == i) { flag = true; break; } } if (!flag) { this.CreateElement(i, ref rect); } } } }
private void UpdateSelectedElement(enExpandListSelectingState selectingState) { switch (selectingState) { case enExpandListSelectingState.Retract: if (this.m_timeSlice < this.m_expandedTime) { this.m_timeSlice += Time.deltaTime; this.m_contentSize = Vector2.zero; Vector2 zero = Vector2.zero; if (this.m_listType == enUIListType.Horizontal) { zero.x += this.m_elementLayoutOffset; } else if (this.m_listType == enUIListType.Vertical) { zero.y += this.m_elementLayoutOffset; } for (int i = 0; i < this.m_elementAmount; i++) { float num = 0f; if (i == this.m_lastSelectedElementIndex) { num = 1f - this.m_timeSlice / this.m_expandedTime; num = Mathf.Clamp(num, 0f, 1f); } stRect stRect = this.LayoutExpandElement(i, num, ref this.m_contentSize, ref zero); if (i < this.m_elementsRect.get_Count()) { this.m_elementsRect.set_Item(i, stRect); } else { this.m_elementsRect.Add(stRect); } } this.ResizeContent(ref this.m_contentSize, false); if (this.m_selectedElementIndex < 0 || this.m_selectedElementIndex >= this.m_elementAmount) { if (this.m_listType == enUIListType.Horizontal) { if (this.m_contentAnchoredPosition.x > 0f) { this.m_contentAnchoredPosition.x = 0f; } else if (this.m_contentAnchoredPosition.x + this.m_contentSize.x < this.m_scrollAreaSize.x) { this.m_contentAnchoredPosition.x = this.m_scrollAreaSize.x - this.m_contentSize.x; } } else if (this.m_listType == enUIListType.Vertical) { if (this.m_contentAnchoredPosition.y < 0f) { this.m_contentAnchoredPosition.y = 0f; } else if (this.m_contentAnchoredPosition.y - this.m_contentSize.y > -this.m_scrollAreaSize.y) { this.m_contentAnchoredPosition.y = -this.m_scrollAreaSize.y + this.m_contentSize.y; } } } } else if (this.m_selectedElementIndex >= 0 && this.m_selectedElementIndex < this.m_elementAmount) { this.m_targetContentAnchoredPosition = this.GetTargetContentAnchoredPosition(this.m_selectedElementIndex); this.m_selectingState = enExpandListSelectingState.Move; this.m_timeSlice = 0f; } else { this.m_selectingState = enExpandListSelectingState.None; } break; case enExpandListSelectingState.Move: if (this.m_contentAnchoredPosition != this.m_targetContentAnchoredPosition) { if (this.m_listType == enUIListType.Horizontal) { int num2 = (this.m_targetContentAnchoredPosition.x <= this.m_contentAnchoredPosition.x) ? -1 : 1; this.m_contentAnchoredPosition.x = this.m_contentAnchoredPosition.x + Time.deltaTime * this.m_contentFixingSpeed * (float)num2; if ((num2 > 0 && this.m_contentAnchoredPosition.x >= this.m_targetContentAnchoredPosition.x) || (num2 < 0 && this.m_contentAnchoredPosition.x <= this.m_targetContentAnchoredPosition.x)) { this.m_contentAnchoredPosition = this.m_targetContentAnchoredPosition; } } else if (this.m_listType == enUIListType.Vertical) { int num3 = (this.m_targetContentAnchoredPosition.y <= this.m_contentAnchoredPosition.y) ? -1 : 1; this.m_contentAnchoredPosition.y = this.m_contentAnchoredPosition.y + Time.deltaTime * this.m_contentFixingSpeed * (float)num3; if ((num3 > 0 && this.m_contentAnchoredPosition.y >= this.m_targetContentAnchoredPosition.y) || (num3 < 0 && this.m_contentAnchoredPosition.y <= this.m_targetContentAnchoredPosition.y)) { this.m_contentAnchoredPosition = this.m_targetContentAnchoredPosition; } } } else { this.m_selectingState = enExpandListSelectingState.Expand; this.m_timeSlice = 0f; } break; case enExpandListSelectingState.Expand: if (this.m_timeSlice < this.m_expandedTime) { this.m_timeSlice += Time.deltaTime; this.m_contentSize = Vector2.zero; Vector2 zero2 = Vector2.zero; if (this.m_listType == enUIListType.Horizontal) { zero2.x += this.m_elementLayoutOffset; } else if (this.m_listType == enUIListType.Vertical) { zero2.y += this.m_elementLayoutOffset; } for (int j = 0; j < this.m_elementAmount; j++) { float num4 = 0f; if (j == this.m_selectedElementIndex) { num4 = this.m_timeSlice / this.m_expandedTime; num4 = Mathf.Clamp(num4, 0f, 1f); } stRect stRect2 = this.LayoutExpandElement(j, num4, ref this.m_contentSize, ref zero2); if (j < this.m_elementsRect.get_Count()) { this.m_elementsRect.set_Item(j, stRect2); } else { this.m_elementsRect.Add(stRect2); } } this.ResizeContent(ref this.m_contentSize, false); } else { this.m_selectingState = enExpandListSelectingState.None; } break; } for (int k = 0; k < this.m_elementAmount; k++) { stRect stRect3 = this.m_elementsRect.get_Item(k); CUIListElementScript elemenet = base.GetElemenet(k); if (elemenet != null) { elemenet.SetRect(ref stRect3); } } this.m_contentRectTransform.anchoredPosition = this.m_contentAnchoredPosition; }