- TalkSceneSO 引入 SceneExit 多出口列表与 displayOrder 排序 - GameManager.NextSceneSo 与 Yarn NextYarn 支持 exitName 跳转 - ChapterController 改用 GameManager 全局 SceneSO 列表 - SceneSO 资源迁移至 Archive/Demo/Fiction/Test 子目录
66 lines
1.5 KiB
C#
66 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Yarn.Unity;
|
|
|
|
namespace AibisDream
|
|
{
|
|
[Serializable]
|
|
public class SceneExit
|
|
{
|
|
[Tooltip("出口名称,用于Yarn命令指定跳转目标,如 good_end / bad_end / default")]
|
|
public string exitName;
|
|
|
|
public TalkSceneSO targetScene;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 章节类型数据
|
|
/// </summary>
|
|
[CreateAssetMenu(menuName = "Game Scene/TalkSceneSO")]
|
|
public class TalkSceneSO : ScriptableObject
|
|
{
|
|
private const string DEFAULT_EXIT_NAME = "default";
|
|
|
|
public List<SceneExit> exits = new();
|
|
public int displayOrder;
|
|
|
|
public YarnProject yarnProject;
|
|
|
|
public string firstSceneName;
|
|
|
|
#region 用于显示的字段
|
|
|
|
public string title;
|
|
public string description;
|
|
public Sprite coverPic;
|
|
public string chapter;
|
|
|
|
#endregion
|
|
|
|
#region 仅编辑器使用
|
|
|
|
[HideInInspector] public Vector2 graphPosition;
|
|
public Color nodeColor = new(0.85f, 0.45f, 0.45f);
|
|
|
|
#endregion
|
|
|
|
public TalkSceneSO GetNextScene(string exitName = null)
|
|
{
|
|
if (exits == null || exits.Count == 0)
|
|
return null;
|
|
|
|
if (string.IsNullOrEmpty(exitName))
|
|
exitName = DEFAULT_EXIT_NAME;
|
|
|
|
foreach (var exit in exits)
|
|
{
|
|
if (exit.exitName == exitName)
|
|
return exit.targetScene;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|