Пример #1
0
        void RenderItem(MidiDirectScrollItemController item, Storage.Protos.Api.MidiProto midi)
        {
            item.nameText.text     = midi.name;
            item.authorText.text   = midi.artistName;
            item.uploaderText.text = "upload by " + midi.uploaderName;
            item.albumText.text    = midi.album == null ? midi.sourceAlbumName : midi.album.name.TranslateArtifact();
            item.songText.text     = midi.song == null ? midi.sourceSongName : midi.song.name.TranslateArtifact();

            if (midi.coverUrl != null)
            {
                web.LoadTexture(midi.coverUrl, job => {
                    item.coverImageCutter.Cut(job.GetKey(), job.GetData());
                });
            }
            else
            {
                item.coverImageCutter.Cut(item.defaultTexture.name, item.defaultTexture);
            }

            item.downloadButton.onClick.RemoveAllListeners();
            item.downloadButton.onClick.AddListener(() => DownloadMidi(item, midi));

            if (web.CheckUrlFileExists(midi.hash))
            {
                item.coverImageCutter.image.color = new Color(1, 1, 1, .5f);
                item.iconText.text = FontAwesome.Solid.CheckCircle;
            }
            else
            {
                item.coverImageCutter.image.color = new Color(1, 1, 1, 1);
                item.iconText.text = FontAwesome.Solid.CloudDownloadAlt;
            }
        }