修复了选曲的问题 优化了ui

This commit is contained in:
2026-01-08 21:04:36 +08:00
parent e7f4ac72d5
commit 2738089af1
414 changed files with 60357 additions and 5279 deletions
@@ -200,6 +200,7 @@ RectTransform:
- {fileID: 660568125378752264}
- {fileID: 5907833122203511268}
- {fileID: 8205711265108694850}
- {fileID: 7990419107466363714}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
@@ -324,6 +325,47 @@ MonoBehaviour:
buttonImage: {fileID: 4974503315116154840}
profileImage: {fileID: 7018466335066945843}
song_songSerialID: 0
selected_boarder: {fileID: 4758992877847013954}
fade_image: {fileID: 8405752277710552670}
minAlpha: 0
maxAlpha: 0.25
blinkDuration: 2
--- !u!1 &1369053455477687453
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7990419107466363714}
m_Layer: 5
m_Name: mark
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &7990419107466363714
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1369053455477687453}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 216602193163554609}
m_Father: {fileID: 5796882771854016848}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &2356119867999498898
GameObject:
m_ObjectHideFlags: 0
@@ -358,7 +400,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 267.45996, y: -40.361988}
m_AnchoredPosition: {x: 264.87, y: -36.736988}
m_SizeDelta: {x: 412, y: 21.276}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8887826047491577449
@@ -633,6 +675,81 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &5538076544640874864
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1029705398409341139}
- component: {fileID: 4227190623302481701}
- component: {fileID: 8405752277710552670}
m_Layer: 5
m_Name: fill
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1029705398409341139
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5538076544640874864}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 216602193163554609}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 1.5}
m_SizeDelta: {x: 752, y: 99}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4227190623302481701
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5538076544640874864}
m_CullTransparentMesh: 1
--- !u!114 &8405752277710552670
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5538076544640874864}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 7f3b1220317607e44bbb8f0e1998044a, type: 3}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 3
--- !u!1 &5974066457956050192
GameObject:
m_ObjectHideFlags: 0
@@ -713,6 +830,81 @@ MonoBehaviour:
m_LineSpacing: 1
m_Text: "\u6B4C\u66F2\u6536\u5F55\u65F6\u95F4\uFF1A2011\u5E7445\u670814\u65E5 |
\u6240\u5C5EDLC\uFF1A\u6211\u7231\u6D6E\u52A8\u6E38\u620F"
--- !u!1 &7397854269593595273
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2612932928907378283}
- component: {fileID: 2072929526885726111}
- component: {fileID: 4758992877847013954}
m_Layer: 5
m_Name: boarder
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2612932928907378283
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7397854269593595273}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 216602193163554609}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 1.5}
m_SizeDelta: {x: 752, y: 99}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2072929526885726111
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7397854269593595273}
m_CullTransparentMesh: 1
--- !u!114 &4758992877847013954
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7397854269593595273}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 7f3b1220317607e44bbb8f0e1998044a, type: 3}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 0
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 3
--- !u!1 &7738832080213160323
GameObject:
m_ObjectHideFlags: 0
@@ -1030,6 +1222,43 @@ MonoBehaviour:
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: "\u6700\u5927\u96BE\u5EA6\u8BC4\u5206"
--- !u!1 &9045718542968113931
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 216602193163554609}
m_Layer: 5
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &216602193163554609
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9045718542968113931}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2612932928907378283}
- {fileID: 1029705398409341139}
m_Father: {fileID: 7990419107466363714}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &9134678205893619106
GameObject:
m_ObjectHideFlags: 0
@@ -1,6 +1,7 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.Collections;
public class SongButton : MonoBehaviour
{
@@ -18,27 +19,47 @@ public class SongButton : MonoBehaviour
[Header("头图")]
public Image profileImage;
public int song_songSerialID;
[Header("select mark")]
public Image selected_boarder;
public Image fade_image;
[Header("Fade Image Settings")]
public float minAlpha = 0f;
public float maxAlpha = 1f;
public float blinkDuration = 0.5f;
private static SongButton currentSelected;
private Coroutine fadeCoroutine;
private Coroutine blinkCoroutine;
public void Start()
{
if (selected_boarder != null)
{
Color c = selected_boarder.color;
c.a = 0f;
selected_boarder.color = c;
}
if (fade_image != null)
{
Color c = fade_image.color;
c.a = 0f;
fade_image.color = c;
}
}
public void SetButtonData(string songName, int highestScore, int difficultyID, Sprite songSprite, int songID)
{
Debug.Log("SetButtonData 被调用, songID 参数: " + songID);
// try to load SongData by id and populate fields from SO when available
var sd = SongDataLibrary.Instance != null ? SongDataLibrary.Instance.GetSongDataByID(songID) : null;
if (sd != null)
{
// song name
if (songNameText != null) songNameText.text = sd.songName;
// multi name text: 音乐:artist | 曲绘:painter | 制谱:level_creator
if (multiNameText != null)
multiNameText.text = "音乐:" + sd.artistName + " | 曲绘:" + sd.painter + " | 制谱:" + sd.level_creator;
// song join time and DLC
if (joinTime_and_dlcName_Text != null)
{
string join = string.IsNullOrEmpty(sd.thisLevel_addDateString) ? "未知" : sd.thisLevel_addDateString;
@@ -46,13 +67,11 @@ public class SongButton : MonoBehaviour
joinTime_and_dlcName_Text.text = "歌曲收录时间:" + join + " | " + "所属DLC" + dlc;
}
// song overall description
if (songOverallDescriptionText != null)
{
songOverallDescriptionText.text = string.IsNullOrEmpty(sd.thisLevel_overallDescription) ? "暂无歌曲简介。" : sd.thisLevel_overallDescription;
}
// compute highest total (chart personal + idol) and its difficulty
int bestTotal = 0;
int bestDiff = -1;
if (sd.personalRecordMap != null)
@@ -71,7 +90,6 @@ public class SongButton : MonoBehaviour
}
}
// fallback: use stored personalRecord and selected difficulty if maps empty
if (bestDiff == -1)
{
bestTotal = sd.personalRecord;
@@ -80,7 +98,6 @@ public class SongButton : MonoBehaviour
if (highestScoreText != null) highestScoreText.text = bestTotal.ToString();
// difficultyIDText: show difficultyLEVEL from ChartFileEntry of bestDiff if available, else show numeric id
string diffDisplay = bestDiff.ToString();
if (sd.chartFiles != null)
{
@@ -95,10 +112,8 @@ public class SongButton : MonoBehaviour
}
if (difficultyIDText != null) difficultyIDText.text = diffDisplay;
// button image
if (buttonImage != null) buttonImage.sprite = sd.backgroudPIC;
// profile image: use card_profileImage from SO
if (profileImage != null)
{
profileImage.sprite = sd.card_profileImage;
@@ -109,7 +124,6 @@ public class SongButton : MonoBehaviour
}
else
{
// hide if no sprite
profileImage.enabled = false;
}
}
@@ -119,7 +133,6 @@ public class SongButton : MonoBehaviour
}
else
{
// fallback to original behavior if SO not found
if (songNameText != null) songNameText.text = songName;
if (highestScoreText != null) highestScoreText.text = "PR: " + highestScore.ToString();
if (difficultyIDText != null) difficultyIDText.text = difficultyID.ToString();
@@ -135,12 +148,95 @@ public class SongButton : MonoBehaviour
SongData selectedSong = SongDataLibrary.Instance.GetSongDataByID(song_songSerialID);
if (selectedSong != null)
{
if (currentSelected != null && currentSelected != this)
{
currentSelected.FadeOutSelectedBorder();
}
currentSelected = this;
FadeInSelectedBorder();
SongDataHolder.SelectedSongData = selectedSong;
SceneManager.LoadScene("Songs_Select");
var selectedInfo = FindObjectOfType<selected_songInfo>();
if (selectedInfo != null)
{
selectedInfo.UpdateSelectedSongDisplay();
}
}
else
{
Debug.LogError("未找到对应的 SongData, songID: " + song_songSerialID);
}
}
private void FadeInSelectedBorder()
{
if (selected_boarder != null)
{
if (fadeCoroutine != null) StopCoroutine(fadeCoroutine);
fadeCoroutine = StartCoroutine(FadeImage(selected_boarder, selected_boarder.color.a, 1f, 0.3f));
}
if (fade_image != null)
{
if (blinkCoroutine != null) StopCoroutine(blinkCoroutine);
blinkCoroutine = StartCoroutine(BlinkFadeImage());
}
}
private void FadeOutSelectedBorder()
{
if (selected_boarder != null)
{
if (fadeCoroutine != null) StopCoroutine(fadeCoroutine);
fadeCoroutine = StartCoroutine(FadeImage(selected_boarder, selected_boarder.color.a, 0f, 0.3f));
}
if (fade_image != null)
{
if (blinkCoroutine != null) StopCoroutine(blinkCoroutine);
fadeCoroutine = StartCoroutine(FadeImage(fade_image, fade_image.color.a, 0f, 0.3f));
}
}
private IEnumerator FadeImage(Image img, float startAlpha, float endAlpha, float duration)
{
if (img == null) yield break;
float time = 0f;
Color color = img.color;
while (time < duration)
{
time += Time.deltaTime;
float alpha = Mathf.Lerp(startAlpha, endAlpha, time / duration);
color.a = alpha;
img.color = color;
yield return null;
}
color.a = endAlpha;
img.color = color;
}
private IEnumerator BlinkFadeImage()
{
if (fade_image == null) yield break;
Color color = fade_image.color;
while (true)
{
float time = 0f;
while (time < blinkDuration / 2f)
{
time += Time.deltaTime;
float alpha = Mathf.Lerp(minAlpha, maxAlpha, time / (blinkDuration / 2f));
color.a = alpha;
fade_image.color = color;
yield return null;
}
time = 0f;
while (time < blinkDuration / 2f)
{
time += Time.deltaTime;
float alpha = Mathf.Lerp(maxAlpha, minAlpha, time / (blinkDuration / 2f));
color.a = alpha;
fade_image.color = color;
yield return null;
}
}
}
}
+84
View File
@@ -0,0 +1,84 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class selected_songInfo : MonoBehaviour
{
public Image t_songCoverImage;
public Image btm_songCoverImage;
public Text songNameText;
[Header("")]
public List<Button> difficultyButtons = new List<Button>();
[Header("enter detail page")]
public Button enterDetailPageButton;
void Start()
{
if (enterDetailPageButton != null)
{
enterDetailPageButton.onClick.AddListener(OnEnterDetailPageClicked);
}
UpdateSelectedSongDisplay();
}
public void UpdateSelectedSongDisplay()
{
if (SongDataHolder.SelectedSongData != null)
{
var song = SongDataHolder.SelectedSongData;
if (t_songCoverImage != null && song.right_pic_top_image != null)
{
t_songCoverImage.sprite = song.right_pic_top_image;
t_songCoverImage.enabled = true;
}
else
{
t_songCoverImage.enabled = false;
}
if (btm_songCoverImage != null && song.right_pic_bottom_image != null)
{
btm_songCoverImage.sprite = song.right_pic_bottom_image;
btm_songCoverImage.enabled = true;
}
else
{
btm_songCoverImage.enabled = false;
}
if (songNameText != null)
{
songNameText.text = song.songName;
}
}
else
{
// Clear display if no song selected
if (t_songCoverImage != null)
{
t_songCoverImage.sprite = null;
t_songCoverImage.enabled = false;
}
if (btm_songCoverImage != null)
{
btm_songCoverImage.sprite = null;
btm_songCoverImage.enabled = false;
}
if (songNameText != null)
{
songNameText.text = "δѡÔñ¸èÇú";
}
}
}
private void OnEnterDetailPageClicked()
{
if (SongDataHolder.SelectedSongData != null)
{
SceneManager.LoadScene("Songs_Select");
}
else
{
Debug.LogWarning("No song selected, cannot enter detail page.");
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 104b04e04203ce248a25ae01c96d9085