剧情+对话完善
This commit is contained in:
@@ -2,11 +2,12 @@ using System.Collections.Generic;
|
||||
using Ichni.Story.Dialogue;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Story.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// 文本块视图。点击后(阶段 2)将通过 Yarn Spinner 进入对应节点的对话。
|
||||
/// 文本块视图。点击后通过 Yarn Spinner 进入对应节点的对话。
|
||||
/// </summary>
|
||||
public class TextBlockView : StoryBlockView
|
||||
{
|
||||
@@ -26,14 +27,14 @@ namespace Ichni.Story.UI
|
||||
public override void Initialize(StoryBlockDefinition def, Vector2 position, StoryBlockState blockState)
|
||||
{
|
||||
// 注意:base.Initialize 末尾会调用 ApplyState(state),届时已生成对应背景
|
||||
base.Initialize(def, position, blockState);
|
||||
|
||||
YarnNodeName = def.yarnNodeName;
|
||||
|
||||
base.Initialize(def, position, blockState);
|
||||
|
||||
if (storyIdText != null)
|
||||
storyIdText.text = def.blockId;
|
||||
|
||||
// 阶段 5 将接入 Unity Localization;此处占位直接显示 titleKey
|
||||
// 当前仍直接显示 titleKey;正式内容接入时需要由 Unity Localization 解析玩家可见标题。
|
||||
if (titleText != null)
|
||||
titleText.text = def.titleKey;
|
||||
}
|
||||
@@ -55,6 +56,8 @@ namespace Ichni.Story.UI
|
||||
{
|
||||
if (_currentVisual != null)
|
||||
{
|
||||
// 旧背景中的 Button 即将被销毁,先主动解绑,防止基类继续持有失效引用。
|
||||
BindInteractionButton(null);
|
||||
Destroy(_currentVisual);
|
||||
_currentVisual = null;
|
||||
}
|
||||
@@ -81,7 +84,12 @@ namespace Ichni.Story.UI
|
||||
|
||||
_currentVisual = Instantiate(prefab, blockRect);
|
||||
_currentVisual.transform.SetAsFirstSibling();
|
||||
|
||||
// 状态视觉可自由调整层级;不再依赖“第一个子物体就是 Button”的脆弱约定。
|
||||
// 通过基类重新绑定,确保每一次状态背景替换后 TextBlock 仍能响应点击。
|
||||
Button interactionButton = _currentVisual.GetComponentInChildren<Button>(true);
|
||||
if (interactionButton == null)
|
||||
Debug.LogWarning($"[TextBlockView] block '{blockId}' 的状态视觉 '{prefab.name}' 缺少 Button,无法点击。");
|
||||
BindInteractionButton(interactionButton);
|
||||
// 背景铺满整个 block
|
||||
if (_currentVisual.transform is RectTransform visualRect)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user