private bool AddChannelInternal(FizzChannelModel _item) { if (_item == null) { return(false); } bool _added = false; if (!_channelsLookup.ContainsKey(_item.Id)) { FizzChannelView _button = Instantiate(ChannelPrefab); _button.gameObject.SetActive(true); _button.transform.SetParent(GetChannelGroup(_item).transform, false); _button.transform.SetAsLastSibling(); _button.transform.localScale = Vector3.one; _button.SetData(_item, HandleChannelSelected); _channelsLookup.Add(_item.Id, _button); _button.gameObject.name = _item.Name; if (!string.IsNullOrEmpty(_item.Meta.Group) && _groupsLookup.ContainsKey(_item.Meta.Group)) { _groupsLookup[_item.Meta.Group].ChannelCount++; } _added = true; } return(_added); }
public void Reset() { if (!_initialized) { Initialize(); } CurrentSelectedChannel = null; foreach (KeyValuePair <string, FizzChannelView> pair in _channelsLookup) { FizzChannelView button = pair.Value; if (button != null) { Destroy(button.gameObject); } } foreach (KeyValuePair <string, FizzChannelGroupView> pair in _groupsLookup) { FizzChannelGroupView group = pair.Value; if (group != null) { Destroy(group.gameObject); } } _channelsLookup.Clear(); _groupsLookup.Clear(); _channelWatchList.Clear(); }
private void HandleChannelSelected(FizzChannelModel data) { if (CurrentSelectedChannel != null) { if (CurrentSelectedChannel.Id.Equals(data.Id)) { if (OnChannelSelected != null) { OnChannelSelected.Invoke(data); } return; } FizzChannelView currentButton = _channelsLookup[CurrentSelectedChannel.Id]; currentButton.SetSelected(false); } CurrentSelectedChannel = data; if (OnChannelSelected != null) { OnChannelSelected.Invoke(data); } FizzChannelView barButton = _channelsLookup[data.Id]; barButton.SetSelected(true); }
public void UpdateGroup(FizzGroupModel group) { if (!_initialized) { Initialize(); } if (_channelsLookup.ContainsKey(group.Channel.Id)) { FizzChannelView button = _channelsLookup[group.Channel.Id]; button.UpdateNameLabel(group.Channel.Name); button.gameObject.name = group.Channel.Name; } }