Files
ichni_Official/Assets/Scripts/Menu/Tutorial/TutorialCollection.cs

44 lines
1.6 KiB
C#
Raw Normal View History

2025-08-11 14:04:06 -04:00
using System.Collections;
using System.Collections.Generic;
using AK.Wwise;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Ichni.Menu
{
[CreateAssetMenu(fileName = "TutorialCollection", menuName = "Ichni/TutorialCollection")]
public class TutorialCollection : SerializedScriptableObject
{
/// <summary>
/// 教程 Key 到教程曲目配置的映射。
/// Key 必须使用小写英文、数字和下划线,例如 <c>chapter0_intro</c>
/// 不要使用章节展示名、曲名或点号作为 Key。
/// </summary>
2025-08-11 14:04:06 -04:00
public Dictionary<string, SongItemData> songs = new Dictionary<string, SongItemData>();
/// <summary>
/// 按 TutorialBlock 配置的稳定 Key 查找教程曲目。
/// 教程运行流程只通过此函数读取集合,避免各处直接访问字典而产生空引用或不一致的错误信息。
/// </summary>
public bool TryGetTutorialSong(string tutorialKey, out SongItemData song)
{
song = null;
if (string.IsNullOrWhiteSpace(tutorialKey))
{
Debug.LogWarning("[TutorialCollection] Tutorial Key 为空,无法查找教程曲目。");
return false;
}
if (songs == null || !songs.TryGetValue(tutorialKey, out song) || song == null)
{
Debug.LogWarning($"[TutorialCollection] 未找到 Tutorial Key '{tutorialKey}' 对应的教程曲目。");
song = null;
return false;
}
return true;
}
2025-08-11 14:04:06 -04:00
}
}