private void OnCloseChannelButtonClicked() { if (!m_ActiveChannelButton || !m_ActiveChannel.Closable) { return; } if (m_ChannelsHistory.ContainsKey(m_ActiveChannel.ID)) { Core.Utility.RingBuffer <ChannelMessageLabel> history = m_ChannelsHistory[m_ActiveChannel.ID]; foreach (ChannelMessageLabel message in history.ToArray()) { Destroy(message.gameObject); } history.RemoveAll(); m_ChannelsHistory.Remove(m_ActiveChannel.ID); } m_ChannelButtons.Remove(m_ActiveChannel.ID); var rectTransform = m_ActiveChannelButton.transform as RectTransform; var index = rectTransform.GetSiblingIndex(); int relativeIndex; if (index == 0) { relativeIndex = 1; } else { relativeIndex = index - 1; } var otherChannelButton = rectTransform.parent.GetChild(relativeIndex).GetComponent <ChannelButton>(); m_ActiveChannel = null; m_ActiveChannelButton = null; SelectChannelButton(otherChannelButton); }
private void SelectChannelButton(ChannelButton channelButton) { // this button is already selected if (m_ActiveChannel == channelButton.Channel) { return; // set the previous button to non-selected } else if (m_ActiveChannel != null) { m_ActiveChannelButton.SetImage(m_ChannelButtonInactiveSprite); m_ActiveChannelButton.SetState(ChannelButtonState.Inactive); } // set the button as selected m_ActiveChannel = channelButton.Channel; m_ActiveChannelButton = channelButton; m_ActiveChannelButton.SetImage(m_ChannelButtonActiveSprite); m_ActiveChannelButton.SetState(ChannelButtonState.Active); // activate the messages of this channel var length = m_ConsoleMessagesContent.transform.childCount; for (int i = 0; i < length; i++) { var child = m_ConsoleMessagesContent.transform.GetChild(i); ChannelMessageLabel channelMessageLabel = child.GetComponent <ChannelMessageLabel>(); if (channelMessageLabel != null) { channelMessageLabel.gameObject.SetActive(channelMessageLabel.Channel == m_ActiveChannel); } } // TODO: Update misc buttons (close, show server messages, ...) }
private void OnChannelButtonClicked(ChannelButton channelButton) { SelectChannelButton(channelButton); }