Beispiel #1
0
        protected override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
        {
            base.DidActivate(firstActivation, addedToHierarchy, screenSystemEnabling);

            if (firstActivation)
            {
                _tableCellTemplate = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => x.name == "LevelListTableCell");

                _blankAvatarIcon = LoadTextureFromResource("CustomAvatar.Resources.mystery-man.png");
                _noAvatarIcon    = LoadTextureFromResource("CustomAvatar.Resources.ban.png");

                CreateTableView();

                rectTransform.sizeDelta = new Vector2(120, 0);
                rectTransform.offsetMin = new Vector2(-60, 0);
                rectTransform.offsetMax = new Vector2(60, 0);
            }

            if (addedToHierarchy)
            {
                _avatarManager.avatarChanged += OnAvatarChanged;

                _avatars.Clear();
                _avatars.Add(new AvatarListItem("No Avatar", _noAvatarIcon));

                SetLoading(true);
                _avatarManager.GetAvatarInfosAsync(avatar => _avatars.Add(new AvatarListItem(avatar)), null, ReloadData);
            }
        }
Beispiel #2
0
        private void ReloadAvatars(bool force = false)
        {
            _avatars.Clear();
            _tableView.ReloadData();

            SetLoading(true);

            _avatars.Add(new AvatarListItem("No Avatar", _noAvatarIcon));
            _avatarManager.GetAvatarInfosAsync(avatar => _avatars.Add(new AvatarListItem(avatar)), null, ReloadData, force);
        }
Beispiel #3
0
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            base.DidActivate(firstActivation, type);

            if (firstActivation)
            {
                _tableCellTemplate = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => x.name == "LevelListTableCell");

                _blankAvatarIcon = LoadTextureFromResource("CustomAvatar.Resources.mystery-man.png");
                _noAvatarIcon    = LoadTextureFromResource("CustomAvatar.Resources.ban.png");

                avatarList.tableView.SetPrivateField("_pageUpButton", upButton);
                avatarList.tableView.SetPrivateField("_pageDownButton", downButton);
                avatarList.tableView.SetPrivateField("_hideScrollButtonsIfNotNeeded", false);

                TableViewScroller scroller = avatarList.tableView.GetPrivateField <TableViewScroller>("_scroller");

                upButton.onClick.AddListener(() =>
                {
                    scroller.PageScrollUp();
                    avatarList.tableView.RefreshScrollButtons(false);
                });

                downButton.onClick.AddListener(() =>
                {
                    scroller.PageScrollDown();
                    avatarList.tableView.RefreshScrollButtons(false);
                });

                avatarList.tableView.dataSource = this;
            }

            if (type == ActivationType.AddedToHierarchy)
            {
                _avatarManager.avatarChanged += OnAvatarChanged;

                _avatars.Clear();
                _avatars.Add(new AvatarListItem("No Avatar", _noAvatarIcon));

                _avatarManager.GetAvatarInfosAsync(avatar =>
                {
                    _avatars.Add(new AvatarListItem(avatar));

                    ReloadData();
                });
            }
        }