public override void SelectElement(int index, bool isDispatchSelectedChangeEvent = true) { if (this.m_selectingState != enExpandListSelectingState.None) { return; } this.m_lastSelectedElementIndex = this.m_selectedElementIndex; this.m_selectedElementIndex = index; if (this.m_lastSelectedElementIndex == this.m_selectedElementIndex) { this.m_selectedElementIndex = -1; } if (this.m_lastSelectedElementIndex >= 0) { CUIListElementScript elemenet = base.GetElemenet(this.m_lastSelectedElementIndex); if (elemenet != null) { elemenet.ChangeDisplay(false); } } if (this.m_selectedElementIndex >= 0) { CUIListElementScript elemenet2 = base.GetElemenet(this.m_selectedElementIndex); if (elemenet2 != null) { elemenet2.ChangeDisplay(true); if (elemenet2.onSelected != null) { elemenet2.onSelected(); } } } base.DispatchElementSelectChangedEvent(); this.m_contentAnchoredPosition = this.m_contentRectTransform.anchoredPosition; this.m_timeSlice = 0f; if (this.m_lastSelectedElementIndex >= 0) { this.m_selectingState = enExpandListSelectingState.Retract; } else if (this.m_selectedElementIndex >= 0) { this.m_targetContentAnchoredPosition = this.GetTargetContentAnchoredPosition(this.m_selectedElementIndex); this.m_selectingState = enExpandListSelectingState.Move; this.m_timeSlice = 0f; } }
public virtual void SelectElement(int index, bool isDispatchSelectedChangeEvent = true) { this.m_lastSelectedElementIndex = this.m_selectedElementIndex; this.m_selectedElementIndex = index; if (this.m_lastSelectedElementIndex == this.m_selectedElementIndex) { if (this.m_alwaysDispatchSelectedChangeEvent) { this.DispatchElementSelectChangedEvent(); } } else { if (this.m_lastSelectedElementIndex >= 0) { CUIListElementScript elemenet = this.GetElemenet(this.m_lastSelectedElementIndex); if (elemenet != null) { elemenet.ChangeDisplay(false); } } if (this.m_selectedElementIndex >= 0) { CUIListElementScript script2 = this.GetElemenet(this.m_selectedElementIndex); if (script2 != null) { script2.ChangeDisplay(true); if (script2.onSelected != null) { script2.onSelected(); } } } if (isDispatchSelectedChangeEvent) { this.DispatchElementSelectChangedEvent(); } } }