Files
ichni_Creator_Studio/Assets/Scripts/StartMenu/LoadProjectTab.cs
2025-05-11 14:12:47 +08:00

50 lines
2.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using TMPro;
using UniRx;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace Ichni.StartMenu
{
public class LoadProjectTab : MonoBehaviour
{
public string projectName;
public TMP_Text projectNameText, lastSavedTimeText, songNameText;
public Button loadButton;
public Image MemuMask;
public void SetUpTab(string projectName, string lastSavedTime, string songName)
{
this.projectName = projectName;
projectNameText.text = projectName;
lastSavedTimeText.text = lastSavedTime;
songNameText.text = songName;
loadButton.onClick.AddListener(LoadProject);
}
private void LoadProject()
{
MemuMask.gameObject.SetActive(true);
InformationTransistor.instance.isLoadedProject = true;
InformationTransistor.instance.loadedProjectName = projectName;
string projectPath = Application.streamingAssetsPath + "/Projects/" + projectName;
InformationTransistor.instance.projectInfo_BM = ES3.Load<ProjectInformation_BM>("ProjectInformation", projectPath + "/ProjectInfo.json");
InformationTransistor.instance.songInfo_BM = ES3.Load<SongInformation_BM>("SongInformation", projectPath + "/SongInfo.json");
ThemeBundleManager.instance.LoadThemeBundles(InformationTransistor.instance.projectInfo_BM.selectedThemeBundleList);
ThemeBundleManager.instance.waitingBundleAmount
.Where(amount => amount == 0) // 当 waitingAmount 变为 0 时触发
.First()
.Subscribe(_ =>
{
Debug.Log("All AssetBundles are loaded. Switching scene.");
SceneManager.LoadScene("EditorScene");
}).AddTo(this);
}
}
}