Esempio n. 1
0
        public TableCell CellForIdx(TableView tableView, int idx)
        {
            AvatarListTableCell tableCell = _tableView.DequeueReusableCellForIdentifier(kTableCellReuseIdentifier) as AvatarListTableCell;

            if (!tableCell)
            {
                tableCell = Instantiate(_tableCellPrefab);
                tableCell.reuseIdentifier = kTableCellReuseIdentifier;
            }

            AvatarListItem avatar = _avatars[idx];
            Sprite         icon   = avatar.icon ? avatar.icon : _blankAvatarIcon;

            tableCell.nameText.text   = avatar.name;
            tableCell.authorText.text = avatar.author;
            tableCell.cover.sprite    = icon;

            return(tableCell);
        }
Esempio n. 2
0
        private AvatarListTableCell CreateTableCellPrefab()
        {
            GameObject gameObject = Instantiate(_levelCollectionViewController.transform.Find("LevelsTableView/TableView/Viewport/Content/LevelListTableCell").gameObject);

            gameObject.name = "AvatarListTableCell";

            LevelListTableCell originalTableCell = gameObject.GetComponent <LevelListTableCell>();

            AvatarListTableCell tableCell = gameObject.AddComponent <AvatarListTableCell>();

            tableCell.Init(originalTableCell);

            DestroyImmediate(originalTableCell);
            DestroyImmediate(gameObject.transform.Find("FavoritesIcon").gameObject);
            DestroyImmediate(gameObject.transform.Find("SongTime").gameObject);
            DestroyImmediate(gameObject.transform.Find("SongBpm").gameObject);
            DestroyImmediate(gameObject.transform.Find("BpmIcon").gameObject);

            return(tableCell);
        }
Esempio n. 3
0
        protected override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
        {
            base.DidActivate(firstActivation, addedToHierarchy, screenSystemEnabling);

            if (firstActivation)
            {
                _tableCellPrefab = CreateTableCellPrefab();

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

                CreateTableView();
                CreateRefreshButton();
            }

            if (addedToHierarchy)
            {
                _avatarManager.avatarChanged += OnAvatarChanged;
                _avatarManager.avatarAdded   += OnAvatarAdded;
                _avatarManager.avatarRemoved += OnAvatarRemoved;

                ReloadAvatars();
            }
        }