修复问题,优化bug和游戏,resource资源拆迁
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user