Example #1
0
        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);
        }