Files
ichni_Creator_Studio/Assets/Scripts/StartMenu/LoadProjectTab.cs
TRAfoer 19ff2f4862 QuickMove!
Signed-off-by: TRAfoer <lhf190@outlook.com>
2025-08-10 16:00:46 +08:00

52 lines
2.1 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 bool isRecovery = false;
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;
InformationTransistor.instance.isRecovery = isRecovery;
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);
}
}
}