修复问题,优化bug和游戏,resource资源拆迁

This commit is contained in:
FloatGaming
2026-02-24 20:59:38 +08:00
parent d5c8966abd
commit 332307d18c
740 changed files with 6964 additions and 23604 deletions
@@ -77,15 +77,10 @@ public class SongButton : MonoBehaviour
{
Debug.Log("SetButtonData called, songID: " + songID);
SongData sd = null;
if (SongDataLibrary.Instance != null)
{
sd = SongDataLibrary.Instance.GetSongDataByID(songID);
}
if (sd == null)
{
sd = thisSong_so as SongData;
}
SongData sd = thisSong_so as SongData;
if (sd != null) sd.LoadPersistent();
if (SongDataLibrary.Instance != null && SongDataLibrary.Instance.IsLoaded)
sd = SongDataLibrary.Instance.GetSongDataByID(songID) ?? sd;
if (sd != null)
{
if (songNameText != null) songNameText.text = sd.songName;
@@ -205,7 +200,7 @@ public class SongButton : MonoBehaviour
{
Debug.Log("Song button clicked, song_songSerialID: " + song_songSerialID);
SongData selectedSong = null;
if (SongDataLibrary.Instance != null)
if (SongDataLibrary.Instance != null && SongDataLibrary.Instance.IsLoaded)
{
selectedSong = SongDataLibrary.Instance.GetSongDataByID(song_songSerialID);
}
@@ -215,6 +210,7 @@ public class SongButton : MonoBehaviour
}
if (selectedSong != null)
{
selectedSong.LoadPersistent();
selectedSong.GetAbsoluteHighestScore(out int bestTotal, out int bestDiff, out string bestDiffName);
if (bestDiff >= 0)
{
+11 -1
View File
@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
@@ -7,6 +7,16 @@ public class SongDataLibrary : MonoBehaviour
public static SongDataLibrary Instance;
private Dictionary<int, SongData> songDataDictionary = new Dictionary<int, SongData>();
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void EnsureRuntimeInstance()
{
if (Instance != null) return;
if (Object.FindAnyObjectByType<SongDataLibrary>() != null) return;
var go = new GameObject(nameof(SongDataLibrary));
Object.DontDestroyOnLoad(go);
go.AddComponent<SongDataLibrary>();
}
// Documentation text normalized.
// Documentation text normalized.
public string[] subfolderNames;
+10 -4
View File
@@ -1,3 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
@@ -6,23 +7,25 @@ public class SongDataLoader : MonoBehaviour
{
private string jsonDirectory;
public List<SongDataSerializable> loadedSongs = new List<SongDataSerializable>();
[SerializeField] private int _yieldEveryNFiles = 5;
void Start()
{
jsonDirectory = Path.Combine(Application.persistentDataPath, "SongDataJson");
LoadAllSongsFromJson();
StartCoroutine(LoadAllSongsFromJsonRoutine());
}
void LoadAllSongsFromJson()
IEnumerator LoadAllSongsFromJsonRoutine()
{
if (!Directory.Exists(jsonDirectory))
{
Debug.LogError("JSON ļвڣ");
return;
yield break;
}
loadedSongs.Clear();
string[] jsonFiles = Directory.GetFiles(jsonDirectory, "*.json");
IEnumerable<string> jsonFiles = Directory.EnumerateFiles(jsonDirectory, "*.json");
int counter = 0;
foreach (string file in jsonFiles)
{
@@ -31,6 +34,9 @@ public class SongDataLoader : MonoBehaviour
loadedSongs.Add(jsonData);
// 由于 SongDataSerializable 现在只存储动态分数,不再包含 songName
Debug.Log($"Loaded persistent song data from: {Path.GetFileName(file)}");
counter++;
if (_yieldEveryNFiles > 0 && counter % _yieldEveryNFiles == 0)
yield return null;
}
}
}