using UnityEngine; using TMPro; using UnityEngine.UI; public class SongDetailsUI : MonoBehaviour { public Image song_bgImage; public TextMeshProUGUI songNameText; public TextMeshProUGUI artistNameText; public TextMeshProUGUI painterNameText; public TextMeshProUGUI difficultyText; public TextMeshProUGUI charterNameText; public TextMeshProUGUI dlcNameText; public TextMeshProUGUI songSerialNumberText; public TextMeshProUGUI personalRecordText; //public Image songImage; public int id_of_thisSong; void Start() { if (SongDataHolder.SelectedSongData != null) { // 读取选中的 SongData SongData song = SongDataHolder.SelectedSongData; song_bgImage.sprite = song.backgroudPIC; // 更新 UI 显示 songNameText.text = song.songName; artistNameText.text = song.artistName; difficultyText.text = song.difficultyID.ToString(); painterNameText.text = song.painter; charterNameText.text = song.level_creator; dlcNameText.text = song.belongsTo_whichDLC; songSerialNumberText.text = song.songID.ToString(); personalRecordText.text = song.personalRecord.ToString(); id_of_thisSong = song.songID; if (song.illustration != null) { //songImage.sprite = song.illustration; //songImage.enabled = true; } else { Debug.LogWarning("歌曲封面为空:" + song.songName); } Debug.Log("加载歌曲数据: " + song.songName); } else { Debug.LogError("SongDataHolder.SelectedSongData 为空!"); } } }