This commit is contained in:
2025-11-11 21:07:02 +08:00
parent 98d86a4aed
commit 845ac9cc27
48 changed files with 1059 additions and 1829 deletions
@@ -67,11 +67,6 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: c3bb987a03bd4284687e2e4bd17ef561
m_Address: Assets/Language/Config/Config Shared Data.asset
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
m_ReadOnly: 0
m_Settings: {fileID: 11400000, guid: 77169ce22e430f64fb36c771815a4a7b, type: 2}
m_SchemaSet:
@@ -41,12 +41,6 @@ MonoBehaviour:
m_SerializedLabels:
- Locale-zh-Hans
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 780b504d9b462a746b7d00d64022773a
m_Address: Config_zh-Hans
m_ReadOnly: 1
m_SerializedLabels:
- Locale-zh-Hans
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: d6149a0fedb6cc24ba2a318aedab1de0
m_Address: FP_Day1_mid_zh-Hans
m_ReadOnly: 1
@@ -41,12 +41,6 @@ MonoBehaviour:
m_SerializedLabels:
- Locale-en
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 02d98e7d7f864944d96d3b345224d9fa
m_Address: Config_en
m_ReadOnly: 1
m_SerializedLabels:
- Locale-en
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 30ab319b5e0bafe46aa622bb93381c7e
m_Address: FP_Day1_mid_en
m_ReadOnly: 1
-8
View File
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: c061e4bd0b3a72d41870cbf36057b904
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,40 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5b11a58205ec3474ca216360e9fa74a8, type: 3}
m_Name: Config Shared Data
m_EditorClassIdentifier:
m_TableCollectionName: Config
m_TableCollectionNameGuidString: c3bb987a03bd4284687e2e4bd17ef561
m_Entries:
- m_Id: 9020903424
m_Key: dialogUI_bubble_aside
m_Metadata:
m_Items: []
- m_Id: 4373118717952
m_Key: dialogUI_bubble_bubble
m_Metadata:
m_Items: []
- m_Id: 7902061260705792
m_Key: dialogUI_param
m_Metadata:
m_Items: []
m_Metadata:
m_Items: []
m_KeyGenerator:
rid: 7917695935159992322
references:
version: 2
RefIds:
- rid: 7917695935159992322
type: {class: DistributedUIDGenerator, ns: UnityEngine.Localization.Tables, asm: Unity.Localization}
data:
m_CustomEpoch: 1745499303839
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: c3bb987a03bd4284687e2e4bd17ef561
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
-23
View File
@@ -1,23 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5be51871efa6c3e4eae1703925c8f5ac, type: 3}
m_Name: Config
m_EditorClassIdentifier:
m_SharedTableData: {fileID: 11400000, guid: c3bb987a03bd4284687e2e4bd17ef561, type: 2}
m_Tables:
- {fileID: 11400000, guid: 02d98e7d7f864944d96d3b345224d9fa, type: 2}
- {fileID: 11400000, guid: 780b504d9b462a746b7d00d64022773a, type: 2}
m_Extensions: []
m_Group: String Table
references:
version: 2
RefIds: []
-8
View File
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 44f370173ae4c0a40a871751e7cb716d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
-35
View File
@@ -1,35 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e9620f8c34305754d8cc9a7e49e852d9, type: 3}
m_Name: Config_en
m_EditorClassIdentifier:
m_LocaleId:
m_Code: en
m_SharedData: {fileID: 11400000, guid: c3bb987a03bd4284687e2e4bd17ef561, type: 2}
m_Metadata:
m_Items: []
m_TableData:
- m_Id: 9020903424
m_Localized: '"charSpace": "0", "maxCharNum": "55"'
m_Metadata:
m_Items: []
- m_Id: 4373118717952
m_Localized: '"charSpace": "0", "maxCharNum": "22"'
m_Metadata:
m_Items: []
- m_Id: 7902061260705792
m_Localized: '"charSpace": "0"'
m_Metadata:
m_Items: []
references:
version: 2
RefIds: []
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 02d98e7d7f864944d96d3b345224d9fa
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -1,35 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e9620f8c34305754d8cc9a7e49e852d9, type: 3}
m_Name: Config_zh-Hans
m_EditorClassIdentifier:
m_LocaleId:
m_Code: zh-Hans
m_SharedData: {fileID: 11400000, guid: c3bb987a03bd4284687e2e4bd17ef561, type: 2}
m_Metadata:
m_Items: []
m_TableData:
- m_Id: 9020903424
m_Localized: '"charSpace": "7", "maxCharNum": "27"'
m_Metadata:
m_Items: []
- m_Id: 4373118717952
m_Localized: '"charSpace": "7", "maxCharNum": "14"'
m_Metadata:
m_Items: []
- m_Id: 7902061260705792
m_Localized: '"charSpace": "7"'
m_Metadata:
m_Items: []
references:
version: 2
RefIds: []
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 780b504d9b462a746b7d00d64022773a
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -203,6 +203,10 @@ MonoBehaviour:
m_Key: chapter_continue
m_Metadata:
m_Items: []
- m_Id: 73229033469382656
m_Key: setting_textSpeed_slow
m_Metadata:
m_Items: []
m_Metadata:
m_Items: []
m_KeyGenerator:
+5 -1
View File
@@ -85,7 +85,7 @@ MonoBehaviour:
m_Metadata:
m_Items: []
- m_Id: 22296675749900
m_Localized: WINDOW MODE
m_Localized: SCREEN MODE
m_Metadata:
m_Items: []
- m_Id: 22296675749901
@@ -220,6 +220,10 @@ MonoBehaviour:
m_Localized: Continue
m_Metadata:
m_Items: []
- m_Id: 73229033469382656
m_Localized: SLOW
m_Metadata:
m_Items: []
references:
version: 2
RefIds:
+5 -1
View File
@@ -89,7 +89,7 @@ MonoBehaviour:
m_Metadata:
m_Items: []
- m_Id: 22296675749900
m_Localized: "\u7A97\u53E3\u6A21\u5F0F"
m_Localized: "\u5C4F\u5E55\u6A21\u5F0F"
m_Metadata:
m_Items: []
- m_Id: 22296675749901
@@ -209,6 +209,10 @@ MonoBehaviour:
m_Metadata:
m_Items:
- rid: 7917695939544875419
- m_Id: 73229033469382656
m_Localized: "\u6162\u901F"
m_Metadata:
m_Items: []
references:
version: 2
RefIds:
File diff suppressed because it is too large Load Diff
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 9e9d31a584a97f447b431fb1cebb3e85
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,24 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6508e9e28418d5e429ba26325d369d2a, type: 3}
m_Name: Bubble Text Style
m_EditorClassIdentifier:
enSpeed:
normalCharSpeed: 0
longCharSpeed: 0
middleCharSpeed: 0
cnSpeed:
normalCharSpeed: 0
longCharSpeed: 0
middleCharSpeed: 0
enCharSpace: 0
cnCharSpace: 0
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: c5db4e4014d7407479058bb76a3c306d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -1,24 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6508e9e28418d5e429ba26325d369d2a, type: 3}
m_Name: Screen Text Style
m_EditorClassIdentifier:
enSpeed:
normalCharSpeed: 0
longCharSpeed: 0
middleCharSpeed: 0
cnSpeed:
normalCharSpeed: 0
longCharSpeed: 0
middleCharSpeed: 0
enCharSpace: 0
cnCharSpace: 0
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 9d6434b6274f58f4e9911355e9e2bb79
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
+22 -9
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using AibisDream.Framework;
using AibisDream.Utility;
using UnityEngine;
using Yarn.Unity;
@@ -18,17 +19,11 @@ namespace AibisDream
public override void RunLine(LocalizedLine dialogueLine, Action onDialogueLineFinished)
{
LineSyncToken lineSyncEvent;
if (lineViewTypes.Contains(dialogueLine.GetCharacterVo().dialogViewType))
{
// 手动推进视图
lineSyncEvent = new LineSyncToken(dialogueLine, onDialogueLineFinished);
bubbleGroup.RunLine(lineSyncEvent);
}
else
if (dialogueLine.GetCharacterVo().dialogViewType == DialogViewType.Screen)
{
// 自动推进视图
lineSyncEvent = new LineSyncToken(dialogueLine, onDialogueLineFinished, true);
if (_screenViewDict.TryGetValue(dialogueLine.GetCharacterVo().dialogViewType, out var view))
lineSyncEvent = LineSyncToken.CreateAuto(dialogueLine, onDialogueLineFinished);
if (_screenViewDict.TryGetValue(DialogViewType.Screen, out var view))
{
view.RunLine(lineSyncEvent);
}
@@ -37,6 +32,24 @@ namespace AibisDream
Debug.LogWarning($"未注册的视图类型: {dialogueLine.GetCharacterVo().dialogViewType}");
}
}
else if (dialogueLine.GetCharacterVo().dialogViewType == DialogViewType.Task)
{
lineSyncEvent = LineSyncToken.CreateImmediate(dialogueLine, onDialogueLineFinished);
if (_screenViewDict.TryGetValue(DialogViewType.Task, out var view))
{
view.RunLine(lineSyncEvent);
}
else
{
Debug.LogWarning($"未注册的视图类型: {dialogueLine.GetCharacterVo().dialogViewType}");
}
}
else
{
// 手动推进视图
lineSyncEvent = LineSyncToken.CreateDefault(dialogueLine, onDialogueLineFinished);
bubbleGroup.RunLine(lineSyncEvent);
}
// 最后交给推进处理
advanceInput.RunLine(lineSyncEvent);
+50 -10
View File
@@ -1,6 +1,8 @@
using System;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using AibisDream.Framework;
using AibisDream.Kit;
using AibisDream.Utility;
using UnityEngine;
@@ -20,19 +22,27 @@ namespace AibisDream
public event Action SkipTextAnima;
public event Action OnAdvance;
public LineSyncToken(LocalizedLine lineInfo, Action nextStep, bool isAutoSkip = false)
public static LineSyncToken CreateAuto(LocalizedLine lineInfo, Action nextStep)
{
return new LineSyncToken(lineInfo, nextStep, new AutoNextTextShown());
}
public static LineSyncToken CreateImmediate(LocalizedLine lineInfo, Action nextStep)
{
return new LineSyncToken(lineInfo, nextStep, new ImmediateTextShown());
}
public static LineSyncToken CreateDefault(LocalizedLine lineInfo, Action nextStep)
{
return new LineSyncToken(lineInfo, nextStep, new DefaultTextShown());
}
public LineSyncToken(LocalizedLine lineInfo, Action nextStep, ITextShown textShown)
{
this.lineInfo = LineInfo.Generate(lineInfo);
_nextStep = nextStep;
state = LineSyncState.PlayText;
if (this.lineInfo.isAutoSkip || isAutoSkip)
{
_textShown = new AutoNextTextShown();
}
else
{
_textShown = new DefaultTextShown();
}
_textShown = textShown;
}
public void TrySkip()
@@ -75,6 +85,7 @@ namespace AibisDream
private void Advance()
{
EnumEventSystem.Global.Send(DialogEventEnum.LineEnd);
OnAdvance?.Invoke();
OnAdvance = null;
_nextStep?.Invoke();
@@ -90,8 +101,20 @@ namespace AibisDream
public async void TextShown()
{
AdvanceDelayToken = new CancellationTokenSource();
EnumEventSystem.Global.Send(DialogEventEnum.LineShown);
await _textShown.OnTextShown(this);
}
public void TextStart()
{
if (state != LineSyncState.Default)
{
Debug.LogWarning($"line{lineInfo.lineId} 状态为{state}, 不能开始文本");
return;
}
state = LineSyncState.PlayText;
EnumEventSystem.Global.Send(DialogEventEnum.LineStart, lineInfo);
}
}
public struct LineInfo
@@ -100,6 +123,7 @@ namespace AibisDream
public string lineText;
public CharacterVo character;
public bool isAutoSkip;
public bool isOption;
public static LineInfo Generate(LocalizedLine dialogueLine)
{
@@ -108,10 +132,18 @@ namespace AibisDream
lineId = dialogueLine.TextID,
lineText = dialogueLine.TextWithoutCharacterName.Text,
character = dialogueLine.GetCharacterVo(),
isAutoSkip = dialogueLine.IsAutoSkipLine()
isAutoSkip = dialogueLine.IsAutoSkipLine(),
isOption = false
};
}
public string GetRecordLine()
{
const string allowedTagsPattern = @"(<|{)(?!\/?(b|i|color)(?=>|\s|=))[^(>|})]+(>|})";
var res = Regex.Replace(lineText, allowedTagsPattern, "");
return res;
}
public int CalcAutoDelayTime()
{
var delayTime = lineText.RemoveRichTextTags().Length * ConstRef.CharacterDelayTime;
@@ -152,6 +184,14 @@ namespace AibisDream
}
}
public class ImmediateTextShown : ITextShown
{
public async Task OnTextShown(LineSyncToken token)
{
token.state = LineSyncState.WaitForAdvance;
}
}
public enum LineSyncState
{
Default,
-75
View File
@@ -1,75 +0,0 @@
using System;
using AibisDream.Framework;
using AibisDream.Utility;
using UnityEngine;
using Yarn.Unity;
namespace AibisDream
{
/// <summary>
/// 对话View,仅用于处理对话文本
/// </summary>
public class LineView : DialogueViewBase
{
// public override void RunLine(LocalizedLine dialogueLine, Action onDialogueLineFinished)
// {
// string lineId = dialogueLine.TextID;
// string shortText = dialogueLine.TextWithoutCharacterName.Text.Length > 30
// ? dialogueLine.TextWithoutCharacterName.Text.Substring(0, 30) + "..."
// : dialogueLine.TextWithoutCharacterName.Text;
//
// Debug.Log($"[对话流程] [{lineId}] ===== 开始处理 =====");
// Debug.Log($"[对话流程] [{lineId}] 文本内容: {shortText}");
//
// EnumEventSystem.Global.Send(DialogEventEnum.LineStart, DialogText.GetLine(dialogueLine));
//
// HandleLineOutput(dialogueLine, NextStep);
//
// if (DialogController.Instance.quickRunMode)
// {
// Debug.Log($"[快速模式] [{lineId}] ===== 快速处理开始 =====");
//
// // 快速模式:直接跳过文本显示并继续
// bool skipResult = DialogCanvasManager.Instance.TrySkipLine(true);
// Debug.Log($"[快速模式] [{lineId}] TrySkipLine结果: {skipResult}");
//
// EnumEventSystem.Global.Send(DialogEventEnum.LineShown);
// Debug.Log($"[快速模式] [{lineId}] LineShown事件已发送");
//
// DialogCanvasManager.Instance.NextStep();
// Debug.Log($"[快速模式] [{lineId}] NextStep已调用");
// Debug.Log($"[快速模式] [{lineId}] ===== 快速处理完成 =====");
// }
// else
// {
// Debug.Log($"[正常模式] [{lineId}] 等待用户交互");
// }
//
// Debug.Log($"[对话流程] [{lineId}] ===== 处理完成 =====");
// return;
//
// void NextStep()
// {
// EnumEventSystem.Global.Send(DialogEventEnum.LineEnd);
// onDialogueLineFinished();
// }
// }
//
// private void HandleLineOutput(LocalizedLine dialogueLine, Action onDialogueLineFinished)
// {
// string lineId = dialogueLine.TextID;
// Debug.Log($"[文本显示] [{lineId}] 开始显示文本");
// DialogCanvasManager.Instance.ShowLine(dialogueLine.TextWithoutCharacterName.Text,
// dialogueLine.GetCharacterVo(), onDialogueLineFinished, dialogueLine.TextID,
// dialogueLine.IsAutoSkipLine());
// }
//
// public override void RunOptions(DialogueOption[] dialogueOptions, Action<int> onOptionSelected)
// {
// Debug.Log($"[选项显示] ===== 显示 {dialogueOptions.Length} 个选项 =====");
// EnumEventSystem.Global.Send(DialogEventEnum.OptionShow);
// var options = DialogOption.GeneOptions(dialogueOptions, onOptionSelected);
// DialogCanvasManager.Instance.ShowOptions(options);
// }
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 465bacc132ec6ce4e85f8e68354f60ad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using AibisDream.Framework;
using AibisDream.Utility;
@@ -18,6 +19,8 @@ namespace AibisDream.FixSystem
[SerializeField] private TMP_Text title;
[SerializeField] private RectTransform textRoot;
[SerializeField] private TMP_Text textForEstimation;
[SerializeField] private int maxLineNum = 10;
private GameObject _textItemPrefab;
private Queue<TypewriterByCharacter> _lineQueue;
@@ -25,8 +28,6 @@ namespace AibisDream.FixSystem
public TaskScreen TaskScreen { get; private set; }
public int maxLineNum = 10;
#endregion
private void Awake()
@@ -94,12 +95,19 @@ namespace AibisDream.FixSystem
ShowTitle(token.lineInfo.character.GetActorName());
// 显示文本
TypewriterCore textItemTypewriter = AddText(token.lineInfo.lineText);
textItemTypewriter.SetTypewriterSpeed(GetTextSpeedValue());
textItemTypewriter.onTextShowed.AddListener(() => OnTextShown(token, textItemTypewriter));
token.state = LineSyncState.PlayText;
token.TextStart();
// 强制更新布局
LayoutRebuilder.ForceRebuildLayoutImmediate(textRoot);
}
private float GetTextSpeedValue()
{
var textSpeedStr = SettingLoader.Instance.TryRead("TextSpeed", out string textSpeed) ? textSpeed : "1";
return float.TryParse(textSpeedStr, NumberStyles.Float, CultureInfo.InvariantCulture, out float result) ? result : 1f;
}
private void OnTextShown(LineSyncToken syncToken, TypewriterCore typewriter)
{
typewriter.onTextShowed.RemoveAllListeners();
@@ -52,8 +52,10 @@ namespace AibisDream
var taskItem = Instantiate(_taskItemPrefab, _taskListParent);
var task = taskItem.GetComponent<TMP_Text>();
task.text = $"\u25cf {token.lineInfo.lineText}";
token.TextStart();
_taskDict[token.lineInfo.lineId] = taskItem;
token.TextShown();
token.ForceAdvance();
LayoutRebuilder.ForceRebuildLayoutImmediate(_taskListParent.GetComponent<RectTransform>());
}
+11
View File
@@ -95,6 +95,17 @@ namespace AibisDream.Framework
}
}
public void UnRegister<T, TE>(T key, Action<TE> onEvent) where T : IConvertible
{
var kv = key.ToInt32(null);
if (!_eventDict.TryGetValue(typeof(T), out var e)) return;
if (e.Length <= kv || e[kv] == null) return;
if (e[kv] is EasyEvent<TE> tempEvent)
{
tempEvent.UnRegister(onEvent);
}
}
public void UnRegister<T>(T key) where T : IConvertible
{
var kv = key.ToInt32(null);
@@ -3,7 +3,6 @@ using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
using UnityEngine.SocialPlatforms;
namespace AibisDream.Framework
{
@@ -17,6 +16,8 @@ namespace AibisDream.Framework
public static LocalizationTable ActorTable { get; private set; }
public static Locale CurrentLocale => LocalizationSettings.SelectedLocale;
static LocalizationKit()
{
#if UNITY_EDITOR
@@ -24,9 +25,15 @@ namespace AibisDream.Framework
#else
_paramTable = new LocalizationTable(ParamTableName);
ActorTable = new LocalizationTable(ActorTableName);
LocalizationSettings.SelectedLocaleChanged += OnLocaleChanged;
#endif
}
private static void OnLocaleChanged(Locale locale)
{
EnumEventSystem.Global.Send(SettingChangeEvent.LocaleChanged, locale);
}
#if UNITY_EDITOR
private static void OnPlayModeChanged(PlayModeStateChange playMode)
{
@@ -37,6 +44,7 @@ namespace AibisDream.Framework
ActorTable?.Dispose();
_paramTable = new LocalizationTable(ParamTableName);
ActorTable = new LocalizationTable(ActorTableName);
LocalizationSettings.SelectedLocaleChanged += OnLocaleChanged;
}
else if (playMode == PlayModeStateChange.ExitingPlayMode)
{
@@ -44,6 +52,7 @@ namespace AibisDream.Framework
ActorTable?.Dispose();
_paramTable = null;
ActorTable = null;
LocalizationSettings.SelectedLocaleChanged -= OnLocaleChanged;
}
}
#endif
+2 -1
View File
@@ -72,6 +72,7 @@ namespace AibisDream
public enum SettingChangeEvent
{
TextSpeed
TextSpeed,
LocaleChanged
}
}
+11 -2
View File
@@ -3,7 +3,6 @@ using System.Globalization;
using AibisDream.Framework;
using AibisDream.Kit;
using UnityEngine;
using UnityEngine.Localization.Settings;
namespace AibisDream
{
@@ -25,6 +24,11 @@ namespace AibisDream
_container.OnWrite += OnSettingChanged;
}
private void Dispose()
{
_container.OnWrite -= OnSettingChanged;
}
private void LoadAllSetting()
{
var settingConfig = _container.ReadAll();
@@ -34,7 +38,7 @@ namespace AibisDream
}
}
private async void OnSettingChanged(string propName, string value)
private void OnSettingChanged(string propName, string value)
{
// 配置项同步
switch (propName)
@@ -83,6 +87,11 @@ namespace AibisDream
public static void Init()
{
if (Instance != null)
{
Instance.Dispose();
Instance = null;
}
Instance = new SettingLoader();
}
-49
View File
@@ -1,49 +0,0 @@
using System;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.UI;
namespace AibisDream
{
[CreateAssetMenu(menuName = "Style/Text Anima Style")]
public class TextAnimaStyle : ScriptableObject
{
public TextSpeed enSpeed;
public TextSpeed cnSpeed;
public float enCharSpace;
public float cnCharSpace;
[Serializable]
public struct TextSpeed
{
public float slowCharSpeed;
public float normalCharSpeed;
public float fastCharSpeed;
}
public float GetTextSpeed(TextSpeedEnum speedEnum, Locale locale)
{
var textSpeed = locale.Identifier.Code switch
{
"en" => enSpeed,
"zh-Hans" => cnSpeed,
_ => cnSpeed,
};
return speedEnum switch
{
TextSpeedEnum.Slow => textSpeed.slowCharSpeed,
TextSpeedEnum.Normal => textSpeed.normalCharSpeed,
TextSpeedEnum.Fast => textSpeed.fastCharSpeed,
_ => textSpeed.normalCharSpeed,
};
}
}
public enum TextSpeedEnum
{
Slow,
Normal,
Fast
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 6508e9e28418d5e429ba26325d369d2a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+11 -11
View File
@@ -1,11 +1,11 @@
using System;
using System.Globalization;
using AibisDream.Framework;
using AibisDream.Kit;
using AibisDream.Utility;
using Febucci.UI.Core;
using TMPro;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.UI;
namespace AibisDream
@@ -29,7 +29,6 @@ namespace AibisDream
[SerializeField] private int idx;
[SerializeField] private int maxWidth;
[SerializeField] private int minWidth;
[SerializeField] private TextAnimaStyle textAnimaStyle;
public ActorRole Role => role;
public int Idx => idx;
@@ -53,8 +52,7 @@ namespace AibisDream
SetStyle(data.bubbleStyle, data.pivotType);
// 注册事件
_typewriter.onTextShowed.AddListener(InvokeLineShown);
LocalizationKit.LocaleChanged += OnLocaleChanged;
EnumEventSystem.Global.Send(SettingChangeEvent.TextSpeed, value);
EnumEventSystem.Global.Register<SettingChangeEvent, string>(SettingChangeEvent.TextSpeed, OnTextSpeedChanged);
}
private void InvokeLineShown()
@@ -79,11 +77,19 @@ namespace AibisDream
_rect.pivot = CommonUtil.GetPivotByType(pivotType);
var spritePath = bubbleStyle.bubbleSpriteAddress.EndsWith("]")
? $"{bubbleStyle.bubbleSpriteAddress}"
: $"{bubbleStyle.bubbleSpriteAddress}[{pivotType.ToString()}]";
: $"{bubbleStyle.bubbleSpriteAddress}[{pivotType}]";
_bubbleImage.sprite = ResourceKit.LoadAssetSync<Sprite>(spritePath);
// 初始化文字速度
var speedStr = SettingLoader.Instance.TryRead("TextSpeed", out string textSpeed) ? textSpeed : "1";
OnTextSpeedChanged(speedStr);
}
private void OnTextSpeedChanged(string value)
{
float speed = float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out float result) ? result : 1f;
_typewriter.SetTypewriterSpeed(speed);
}
private void InitRefs()
@@ -131,12 +137,6 @@ namespace AibisDream
}
}
public void OnLocaleChanged(Locale locale)
{
// _typewriter.TypingSpeed = textAnimaStyle.GetTextSpeed(TextSpeedEnum.Normal, locale);
_typewriter.SetTypewriterSpeed(textAnimaStyle.GetTextSpeed(TextSpeedEnum.Normal, locale));
}
public void Hide()
{
gameObject.SetActive(false);
+36 -113
View File
@@ -11,7 +11,7 @@ using UnityEngine;
namespace AibisDream
{
public class BubbleGroup : Singleton<BubbleGroup>, IDialogView, ILineView
public class BubbleGroup : Singleton<BubbleGroup>, ILineView
{
[SerializeField] private TMP_Text widthEstimation;
[SerializeField] private CenterBubble centerBubble;
@@ -35,13 +35,6 @@ namespace AibisDream
{
// 工厂
_bubbleFactory = new BubbleFactory(transform);
// 加载选项
InitOptions();
}
private void Start()
{
HideDialog();
}
public override void OnSingletonDestroy()
@@ -64,41 +57,58 @@ namespace AibisDream
.ToDictionary(group => group.Key, group => group.ToArray());
}
private void InitOptions()
{
_bubbleDict = new Dictionary<ActorRole, Bubble[]>();
}
#endregion
#region
#region
public void ShowLine(string dialogLine, CharacterVo character, Action nextStep, string lineId,
bool isAutoSkip = false)
public void RunLine(LineSyncToken syncToken)
{
Debug.Log($"[BubbleGroup] ShowLine - 开始显示对话: {lineId}");
Debug.Log($"[BubbleGroup] ShowLine - nextStep是否为null: {nextStep == null}");
// 先中断原来的事件
_autoHideToken?.Cancel();
_autoHideToken = null;
gameObject.SetActive(true);
var character = syncToken.lineInfo.character;
if (TryGetBubble(character.role, character.bubbleIdx, out var bubble))
{
// 注册事件
bubble.OnLineShown += syncToken.TextShown;
syncToken.SkipTextAnima += () => bubble.SkipLine();
syncToken.OnAdvance += AfterAdvance;
// 播放文字
bubble.ShowActorName(character);
bubble.ShowLine(dialogLine);
bubble.ShowLine(syncToken.lineInfo.lineText);
syncToken.TextStart();
// 将非选定的Bubble隐藏
HideDialog(bubble);
}
else
{
Debug.LogWarning($"{character.GetActorName()}的Role没有对应Bubble");
return;
Debug.LogWarning($"{character.GetActorName()}的Role {character.role}没有对应Bubble");
HideDialog();
}
}
// 保留信息
_nextStep = nextStep;
_curBubble = bubble;
public float EstimateTextWidth(string text, float fontSize)
{
widthEstimation.fontSize = fontSize;
widthEstimation.text = text;
widthEstimation.ForceMeshUpdate();
return widthEstimation.preferredWidth;
}
Debug.Log($"[BubbleGroup] ShowLine - 设置完成,_nextStep是否为null: {_nextStep == null}");
private async void AfterAdvance()
{
_autoHideToken = new CancellationTokenSource();
try
{
await Task.Delay(ConstRef.AutoHideDelay, _autoHideToken.Token);
HideDialog();
}
catch (TaskCanceledException)
{
// 忽略取消
}
}
public void HideDialog()
@@ -111,39 +121,6 @@ namespace AibisDream
centerBubble.Hide();
}
public bool TrySkipLine(bool isForceSkip = false)
{
if (_curBubble == null)
{
return true;
}
return _curBubble.SkipLine();
}
public void NextStep()
{
Debug.Log($"[BubbleGroup] NextStep - _nextStep是否为null: {_nextStep == null}");
if (_nextStep == null)
{
Debug.Log("[BubbleGroup] NextStep - _nextStep为null,提前返回");
return;
}
var next = _nextStep;
_nextStep = null;
_curBubble?.Hide();
_curBubble = null;
next?.Invoke();
}
public void OnLocalizationChanged(string value)
{
}
private void HideDialog(IBubble activeBubble)
{
foreach (var textBubble in _bubbleDict.Values.SelectMany(inner => inner))
@@ -179,59 +156,5 @@ namespace AibisDream
}
#endregion
#region
public void RunLine(LineSyncToken syncToken)
{
// 先中断原来的事件
_autoHideToken?.Cancel();
_autoHideToken = null;
var character = syncToken.lineInfo.character;
if (TryGetBubble(character.role, character.bubbleIdx, out var bubble))
{
// 注册事件
bubble.OnLineShown += syncToken.TextShown;
syncToken.SkipTextAnima += () => bubble.SkipLine();
syncToken.OnAdvance += AfterAdvance;
// 播放文字
bubble.ShowActorName(character);
bubble.ShowLine(syncToken.lineInfo.lineText);
syncToken.state = LineSyncState.PlayText;
// 将非选定的Bubble隐藏
HideDialog(bubble);
}
else
{
Debug.LogWarning($"{character.GetActorName()}的Role {character.role}没有对应Bubble");
HideDialog();
}
}
public float EstimateTextWidth(string text, float fontSize)
{
widthEstimation.fontSize = fontSize;
widthEstimation.text = text;
widthEstimation.ForceMeshUpdate();
return widthEstimation.preferredWidth;
}
private async void AfterAdvance()
{
_autoHideToken = new CancellationTokenSource();
try
{
await Task.Delay(ConstRef.AutoHideDelay, _autoHideToken.Token);
HideDialog();
}
catch (TaskCanceledException)
{
// 忽略取消
}
}
#endregion
}
}
@@ -1,80 +0,0 @@
using System;
using AibisDream.Framework;
using AibisDream.Kit;
using AibisDream.Utility;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace AibisDream
{
public class CenterOption : MonoBehaviour, IDialogView
{
#region
public GameObject choiceButtonPrefab;
#endregion
private TextParam _textParam;
private void Awake()
{
EnumEventSystem.Global.Register<DialogEventEnum, DialogText>(DialogEventEnum.OptionSelected,
_ => HideDialog());
}
public void ShowLine(string dialogLine, CharacterVo character, Action nextStep, string lineId, bool isAutoSkip = false)
{
Debug.Log("CenterOption只显示选项");
}
public void ShowOptions(DialogOption[] dialogueOptions)
{
gameObject.SetActive(true);
// 销毁原来的按钮
foreach (Transform child in transform)
{
Destroy(child.gameObject);
}
// 生成新按钮
foreach (var option in dialogueOptions)
{
if (!option.IsAvailable) continue;
var choiceInstance = Instantiate(choiceButtonPrefab, transform);
var optionText = choiceInstance.GetComponentInChildren<TextMeshProUGUI>();
optionText.text = option.Line;
optionText.characterSpacing = _textParam.charSpace;
choiceInstance.GetComponent<Button>().onClick.AddListener(() =>
{
HideDialog();
option.Select();
});
}
}
public void HideDialog()
{
gameObject.SetActive(false);
}
public bool TrySkipLine(bool isForceSkip)
{
// 无法跳过
return true;
}
public void NextStep()
{
// 无法继续
}
public void OnLocalizationChanged(string value)
{
_textParam = JsonUtil.ReadBeanByText<TextParam>(value);
}
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 144fae82f06c3c248b4fb76f6823baba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
-96
View File
@@ -1,96 +0,0 @@
using System;
using AibisDream.Framework;
using AibisDream.Kit;
using AibisDream.Utility;
using Febucci.UI;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace AibisDream
{
public class CenterText : MonoBehaviour, IDialogView
{
#region
private TypewriterByCharacter _dialogText;
private Action _nextStep;
#endregion
private TextParam _textParam;
private void Awake()
{
InitComponents();
}
private void InitComponents()
{
_dialogText = transform.Find("Dialog Text")?.gameObject.GetComponent<TypewriterByCharacter>();
}
public void ShowLine(string dialogLine, CharacterVo character, Action nextStep, string lineId, bool isAutoSkip = false)
{
// 把原有对话清掉
ClearBox();
_dialogText.gameObject.SetActive(true);
// 显示内容
_dialogText.ShowText(dialogLine);
// 自动跳过的回调很难独立Remove,只能全部清空再注册,下策
_dialogText.onTextShowed.RemoveAllListeners();
_dialogText.onTextShowed.AddListener(() => EnumEventSystem.Global.Send(DialogEventEnum.LineShown));
_nextStep = nextStep;
}
public void ShowOptions(DialogOption[] dialogueOptions)
{
// 不能出选项
}
public void HideDialog()
{
gameObject.SetActive(false);
}
public bool TrySkipLine(bool isForceSkip)
{
if (_dialogText.isShowingText)
{
_dialogText.SkipTypewriter();
return true;
}
return false;
}
public void NextStep()
{
if (_nextStep == null) return;
ClearBox();
var next = _nextStep;
_nextStep = null;
next.Invoke();
}
public void OnLocalizationChanged(string value)
{
_textParam = JsonUtil.ReadBeanByText<TextParam>(value);
var tmp = _dialogText.GetComponent<TMP_Text>();
// 修改对话文本
tmp.characterSpacing = _textParam.charSpace;
}
private void ClearBox()
{
gameObject.SetActive(true);
_dialogText?.TextAnimator.SetText("");
}
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: d6722100b986b0f42994441d3c0aa9e7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,4 +1,5 @@
using System.Linq;
using AibisDream.Framework;
using UnityEngine;
namespace AibisDream
@@ -13,6 +14,9 @@ namespace AibisDream
.OrderBy(item => item.optionIdx)
.ToArray();
HideOptions();
EnumEventSystem.Global.Register<DialogEventEnum, LineInfo>(DialogEventEnum.OptionSelected,
_ => HideOptions());
}
public void ShowOptions(DialogOption[] dialogueOptions)
@@ -1,366 +0,0 @@
using System;
using System.Collections.Generic;
using AibisDream.Framework;
using AibisDream.Kit;
using AibisDream.UI;
using UnityEngine;
namespace AibisDream
{
public class DialogCanvasManager : Singleton<DialogCanvasManager>
{
// #region 引用
//
// private readonly Dictionary<DialogViewType, IDialogView> _dialogViewDict = new();
// private IDialogView _defaultView;
// private IDialogView _showingView;
//
// private IActionController _autoNext;
// private IActionController _block;
// private IActionController _hideDialog;
//
// #endregion
//
// #region 参数
//
// [SerializeField] private float blockDuration;
// [SerializeField] private float autoSkipDelay;
// [SerializeField] private float autoHideDuration;
//
// private bool _isNextAutoSkip;
// private bool _isNextBlocked;
//
// #endregion
//
// private readonly List<IUnRegister> _rmvList = new();
//
// public override void OnSingletonInit()
// {
// InitEvent();
// }
//
// private void Start()
// {
// // 默认对话框直接加载
// var centerText = transform.Find("Center Text").GetComponent<IDialogView>();
// RegisterDialogView(DialogViewType.CenterText, centerText);
// var centerOption = transform.Find("Center Option").GetComponent<IDialogView>();
// RegisterDialogView(DialogViewType.CenterOption, centerOption);
// var bubbleGroup = transform.Find("Bubble Group").GetComponent<IDialogView>();
// RegisterDialogView(DialogViewType.StandardBubble, bubbleGroup);
//
// _defaultView = _dialogViewDict[DialogViewType.StandardBubble];
// }
//
// private void InitEvent()
// {
// // 记录相关
// _rmvList.Add(
// EnumEventSystem.Global.Register<DialogEventEnum, DialogText>(DialogEventEnum.LineStart,
// AddDialogueLine));
// _rmvList.Add(
// EnumEventSystem.Global.Register<DialogEventEnum, DialogText>(DialogEventEnum.OptionSelected,
// AddDialogueLine));
// _rmvList.Add(EnumEventSystem.Global.Register(EventEnum.NextYarn, CleanDialogHistory));
//
// // 文本显示事件
// _rmvList.Add(EnumEventSystem.Global.Register(DialogEventEnum.LineShown, OnTextShown));
// _rmvList.Add(EnumEventSystem.Global.Register(DialogEventEnum.LineEnd, OnTextEnd));
// }
//
// private void OnTextShown()
// {
// Debug.Log("[事件处理] OnTextShown - 文本显示完成事件");
//
// // 在快速模式下,不设置阻塞,因为快速模式会立即处理
// if (DialogController.Instance.quickRunMode)
// {
// Debug.Log("[事件处理] OnTextShown - 快速模式,跳过阻塞设置");
// return;
// }
//
// // 阻塞部分 - 只在非快速模式下阻塞,确保文本能够显示
// _isNextBlocked = true;
// _block = ActionKit.Delay(blockDuration, () =>
// {
// Debug.Log("[事件处理] OnTextShown - 阻塞时间结束");
// _isNextBlocked = false;
// _block = null;
// }
// ).Start(this);
//
// // 自动跳过部分 - 只在非快速模式下执行
// if (DialogController.Instance.autoRunMode || _isNextAutoSkip)
// {
// Debug.Log("[事件处理] OnTextShown - 设置自动跳过定时器");
// _autoNext = ActionKit.Delay(autoSkipDelay, () =>
// {
// Debug.Log("[事件处理] OnTextShown - 自动跳过定时器触发");
// _autoNext = null;
// NextStep();
// }).Start(this);
// _isNextAutoSkip = false;
// }
// }
//
// private void OnTextEnd()
// {
// Debug.Log("[事件处理] OnTextEnd - 文本结束事件");
//
// // 清理阻塞定时器
// if (_block != null)
// {
// Debug.Log("[事件处理] OnTextEnd - 清理阻塞定时器");
// _block.Deinit();
// _block = null;
// }
// _isNextBlocked = false;
//
// // 清理自动跳过定时器
// if (_autoNext != null)
// {
// Debug.Log("[事件处理] OnTextEnd - 清理自动跳过定时器");
// _autoNext.Deinit();
// _autoNext = null;
// }
//
// Debug.Log("[事件处理] OnTextEnd - 清理完成");
// }
//
// public override void OnSingletonDestroy()
// {
// // 销毁前处理事件
// _rmvList.ForEach(item => item.UnRegister());
// }
//
// #region 对话结束后隐藏
//
// private void OnEnable()
// {
// EnumEventSystem.Global.Register(InteractionEventEnum.DialogStart, HideDialog);
// }
//
// private void OnDisable()
// {
// EnumEventSystem.Global.Register(InteractionEventEnum.DialogStart, HideDialog);
// }
//
// #endregion
//
// #region 对话框相关处理
//
// /// <summary>
// /// 注册对话框
// /// </summary>
// /// <param name="viewType"></param>
// /// <param name="dialogView"></param>
// public void RegisterDialogView(DialogViewType viewType, IDialogView dialogView)
// {
// _dialogViewDict.Add(viewType, dialogView);
// }
//
// /// <summary>
// /// 注销对话框
// /// </summary>
// /// <param name="viewType"></param>
// public void UnregisterDialogView(DialogViewType viewType)
// {
// _dialogViewDict.Remove(viewType);
// }
//
// #endregion
//
// #region 对话框接口
//
// public void ShowLine(string dialogLine, CharacterVo character, Action nextStep, string lineId,
// bool isAutoSkip = false)
// {
// Debug.Log($"[DialogCanvasManager] ShowLine - 角色对话框类型: {character.dialogViewType}");
// Debug.Log($"[DialogCanvasManager] ShowLine - nextStep是否为null: {nextStep == null}");
//
// _isNextAutoSkip = isAutoSkip;
// // 根据DialogViewType确定在哪个对话框显示
// if (character.dialogViewType == DialogViewType.Default)
// {
// Debug.Log("[DialogCanvasManager] ShowLine - 使用默认对话框");
// if (_showingView != _defaultView)
// {
// _showingView?.HideDialog();
// }
// else
// {
// _hideDialog?.Deinit();
// _hideDialog = null;
// }
//
// _showingView = _defaultView;
//
// _showingView.ShowLine(dialogLine, character, nextStep, lineId, isAutoSkip);
// }
// else if (_dialogViewDict.TryGetValue(character.dialogViewType, out var view))
// {
// Debug.Log($"[DialogCanvasManager] ShowLine - 使用指定对话框: {view.GetType().Name}");
// if (_showingView != view)
// {
// _showingView?.HideDialog();
// }
// else
// {
// _hideDialog?.Deinit();
// _hideDialog = null;
// }
//
// _showingView = view;
//
// // 对于指定了对话框的,就在指定对话框显示
// view.ShowLine(dialogLine, character, nextStep, lineId, isAutoSkip);
// }
// else
// {
// Debug.Log($"{character.dialogViewType.ToString()}类型对话框不存在");
// }
//
// Debug.Log($"[DialogCanvasManager] ShowLine - 当前_showingView类型: {_showingView?.GetType().Name}");
// }
//
// public void ShowOptions(DialogOption[] dialogueOptions)
// {
// var viewType = dialogueOptions[0].Character.dialogViewType;
// // 根据状况选择不同的选择框
// if (viewType == DialogViewType.Default)
// {
// if (_showingView != _defaultView)
// {
// _showingView?.HideDialog();
// }
// else
// {
// _hideDialog?.Deinit();
// _hideDialog = null;
// }
// _showingView = _defaultView;
//
// _showingView.ShowOptions(dialogueOptions);
// }
// else if(_dialogViewDict.TryGetValue(viewType, out var view))
// {
// if (_showingView != view)
// {
// _showingView?.HideDialog();
// }
// else
// {
// _hideDialog?.Deinit();
// _hideDialog = null;
// }
// _showingView = view;
// _showingView.ShowOptions(dialogueOptions);
// }
// }
//
// public void HideDialog()
// {
// _showingView?.HideDialog();
// }
//
// public bool TrySkipLine(bool isForceSkip = false)
// {
// string skipType = isForceSkip ? "强制跳过" : "用户跳过";
// Debug.Log($"[跳过操作] {skipType} - 阻塞状态: {_isNextBlocked}");
//
// if (_isNextBlocked)
// {
// Debug.Log("[跳过操作] ❌ 被阻塞,返回true");
// return true;
// }
//
// bool result = _showingView != null && _showingView.TrySkipLine(isForceSkip);
// Debug.Log($"[跳过操作] {skipType} - 结果: {(result ? "✅ 成功" : "❌ 失败")}");
// return result;
// }
//
// public void NextStep()
// {
// Debug.Log("[对话继续] ===== NextStep开始 =====");
// Debug.Log($"[对话继续] 当前显示的对话框类型: {_showingView?.GetType().Name}");
//
// // 在快速模式下,不设置延迟隐藏,避免定时器冲突
// if (!DialogController.Instance.quickRunMode)
// {
// var view = _showingView;
// _hideDialog = ActionKit.Delay(autoHideDuration, () =>
// {
// Debug.Log("[对话继续] 延迟隐藏对话框");
// _hideDialog = null;
// view?.HideDialog();
// }).Start(this);
// }
// else
// {
// Debug.Log("[对话继续] 快速模式,跳过延迟隐藏设置");
// // 清理可能存在的延迟隐藏定时器
// if (_hideDialog != null)
// {
// _hideDialog.Deinit();
// _hideDialog = null;
// }
// }
//
// Debug.Log("[对话继续] 调用对话框NextStep");
// _showingView?.NextStep();
//
// Debug.Log("[对话继续] ===== NextStep完成 =====");
// }
//
// public void OnLocalizationChanged(string value)
// {
// }
//
// #endregion
//
// #region 对话回顾
//
// private RecordPanel RecordPanel => UIManager.Instance.GetPanel<RecordPanel>();
//
// /// <summary>
// /// 记录对话
// /// </summary>
// /// <param name="line">对话</param>
// private void AddDialogueLine(DialogText line)
// {
// if (line.actor.dialogViewType == DialogViewType.Task)
// {
// return;
// }
//
// RecordPanel.AppendDialogLine(line);
// }
//
// private void CleanDialogHistory()
// {
// RecordPanel.ClearDialog();
// }
//
// public void CloseCanvas()
// {
// gameObject.SetActive(false);
// }
//
// public void OpenCanvas()
// {
// gameObject.SetActive(true);
// }
//
// #endregion
}
public enum DialogViewType
{
Default,
Screen,
CenterText,
CenterOption,
Task,
StandardBubble
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c14c52217dac70244b02fe48d9462bae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -8,21 +8,6 @@ using Yarn.Unity;
namespace AibisDream
{
public interface IDialogView
{
public void ShowLine(string dialogLine, CharacterVo character, Action nextStep, string lineId ,bool isAutoSkip = false);
public void ShowOptions(DialogOption[] dialogueOptions) {}
public void HideDialog();
public bool TrySkipLine(bool isForceSkip = false);
public void NextStep();
public void OnLocalizationChanged(string value);
}
public struct DialogOption
{
private Action<int> _onOptionSelected;
@@ -47,14 +32,15 @@ namespace AibisDream
_onOptionSelected.Invoke(_option.DialogueOptionID);
}
private DialogText TransToLine()
private LineInfo TransToLine()
{
return new DialogText
return new LineInfo
{
isOption = true,
lineId = _option.TextID,
line = _option.Line.TextWithoutCharacterName.Text,
actor = _option.Line.GetCharacterVo()
lineText = _option.Line.TextWithoutCharacterName.Text,
character = _option.Line.GetCharacterVo(),
isAutoSkip = false
};
}
+42 -11
View File
@@ -1,4 +1,6 @@
using AibisDream.Kit;
using AibisDream.Framework;
using AibisDream.Kit;
using AibisDream.UI;
using UnityEngine;
namespace AibisDream
@@ -13,6 +15,38 @@ namespace AibisDream
public override void OnSingletonInit()
{
_canvasGroup = GetComponent<CanvasGroup>();
EnumEventSystem.Global.Register<DialogEventEnum, LineInfo>(DialogEventEnum.LineStart, AddDialogueLine);
EnumEventSystem.Global.Register<DialogEventEnum, LineInfo>(DialogEventEnum.OptionSelected, AddDialogueLine);
EnumEventSystem.Global.Register(EventEnum.NextYarn, CleanDialogHistory);
}
public override void OnSingletonDestroy()
{
EnumEventSystem.Global.UnRegister<DialogEventEnum, LineInfo>(DialogEventEnum.LineStart, AddDialogueLine);
EnumEventSystem.Global.UnRegister<DialogEventEnum, LineInfo>(DialogEventEnum.OptionSelected, AddDialogueLine);
EnumEventSystem.Global.UnRegister(EventEnum.NextYarn, CleanDialogHistory);
}
private RecordPanel RecordPanel => UIManager.Instance.GetPanel<RecordPanel>();
/// <summary>
/// 记录对话
/// </summary>
/// <param name="line">对话</param>
private void AddDialogueLine(LineInfo line)
{
if (line.character.dialogViewType == DialogViewType.Task)
{
return;
}
RecordPanel.AppendDialogLine(line);
}
private void CleanDialogHistory()
{
RecordPanel.ClearDialog();
}
public void CloseCanvas()
@@ -40,18 +74,15 @@ namespace AibisDream
{
lineView.UnRegisterView(dialogViewType);
}
public void ChangeTextSpeed(float speed)
{
// lineView.ChangeTextSpeed(speed);
}
}
public enum TextSpeedMode
public enum DialogViewType
{
Slow,
Middle,
Fast,
Immidiate
Default,
Screen,
CenterText,
CenterOption,
Task,
StandardBubble
}
}
+2 -2
View File
@@ -12,9 +12,9 @@ namespace AibisDream.UI
#endregion
public void Init(DialogText dialogText)
public void Init(LineInfo dialogText)
{
actorName.text = dialogText.actor.GetActorName();
actorName.text = dialogText.character.GetActorName();
dialogLine.text = dialogText.GetRecordLine();
gameObject.SetActive(true);
}
+3 -10
View File
@@ -22,7 +22,7 @@ namespace AibisDream.UI
#endregion
private readonly List<DialogText> _recordDataList = new();
private readonly List<LineInfo> _recordDataList = new();
public void Show()
{
@@ -65,9 +65,9 @@ namespace AibisDream.UI
popupBackground.CrossFadeAlpha(0.0f, 0.2f, false);
}
public void AppendDialogLine(DialogText dialogText)
public void AppendDialogLine(LineInfo lineInfo)
{
_recordDataList.Add(dialogText);
_recordDataList.Add(lineInfo);
}
public void ClearDialog()
@@ -77,13 +77,6 @@ namespace AibisDream.UI
private void ShowRecord()
{
// for (var i = _recordDataList.Count - 1; i >= 0; i--)
// {
// var dialogText = _recordDataList[i];
// var record = Instantiate(recordPrefab, recordRoot);
// record.GetComponent<RecordItem>().Init(dialogText);
// }
foreach (var recordData in _recordDataList)
{
var record = Instantiate(recordPrefab, recordRoot);
+2 -1
View File
@@ -1,5 +1,6 @@
{
"Volume": "0.89",
"Language": "zh-Hans",
"WindowMode": "Windowed"
"WindowMode": "Windowed",
"TextSpeed": "2.0"
}