新对话记录

This commit is contained in:
2025-09-19 20:50:09 +08:00
parent 644f530304
commit 541dfdc6b2
10 changed files with 570 additions and 730 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 62fe16447b58e0a4488420a0ebfdd353
guid: d6e8f35aaa8c40c4e917cc9e1671915e
folderAsset: yes
DefaultImporter:
externalObjects: {}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ab3222005e06e4c4aad63f7fd097f61c
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
+1 -3
View File
@@ -1,6 +1,5 @@
using System;
using AibisDream.Framework;
using AibisDream.Kit;
using AibisDream.Utility;
using UnityEngine;
using Yarn.Unity;
@@ -19,8 +18,7 @@ namespace AibisDream
Debug.Log($"[对话流程] [{lineId}] ===== 开始处理 =====");
Debug.Log($"[对话流程] [{lineId}] 文本内容: {shortText}");
EnumEventSystem.Global.Send(DialogEventEnum.LineStart,
DialogText.GetLine(dialogueLine, DialogController.Instance.GetCurLocalizedTableName()));
EnumEventSystem.Global.Send(DialogEventEnum.LineStart, DialogText.GetLine(dialogueLine));
HandleLineOutput(dialogueLine, onDialogueLineFinished);
+9 -4
View File
@@ -45,19 +45,24 @@ namespace AibisDream
public string line;
public CharacterVo actor;
public string lineId;
public string localizationTableName;
public static DialogText GetLine(LocalizedLine dialogueLine, string projName)
public static DialogText GetLine(LocalizedLine dialogueLine)
{
return new DialogText
{
isOption = false,
line = dialogueLine.TextWithoutCharacterName.Text,
lineId = dialogueLine.TextID,
actor = dialogueLine.GetCharacterVo(),
localizationTableName = projName
actor = dialogueLine.GetCharacterVo()
};
}
public string GetRecordLine()
{
const string allowedTagsPattern = @"(<|{)(?!\/?(b|i|color)(?=>|\s|=))[^(>|})]+(>|})";
var res = Regex.Replace(line, allowedTagsPattern, "");
return res;
}
}
public enum StorageEvent
+5 -13
View File
@@ -1,6 +1,5 @@
using AibisDream.Utility;
using TMPro;
using UnityEngine;
using UnityEngine.Localization.Components;
namespace AibisDream.UI
{
@@ -8,23 +7,16 @@ namespace AibisDream.UI
{
#region
[SerializeField] private LocalizeStringEvent actorName;
[SerializeField] private LocalizeStringEvent dialogLine;
[SerializeField] private TMP_Text actorName;
[SerializeField] private TMP_Text dialogLine;
#endregion
public void Init(DialogText dialogText)
{
actorName.text = dialogText.actor.GetActorName();
dialogLine.text = dialogText.GetRecordLine();
gameObject.SetActive(true);
actorName.SetTable(ConstRef.ActorNameTable);
actorName.SetEntry(dialogText.actor.key);
dialogLine.SetTable(dialogText.localizationTableName);
dialogLine.SetEntry(dialogText.lineId);
}
public void Dispose()
{
gameObject.SetActive(false);
}
}
}
+12 -12
View File
@@ -12,17 +12,15 @@ namespace AibisDream.UI
public bool IsCloseable => true;
#region
[SerializeField] private Image popupBackground;
[SerializeField] private Button closeBtn;
[SerializeField] private LoopVerticalScrollRect recordScroll;
[SerializeField] private Transform content;
[SerializeField] private Transform inactiveRoot;
[SerializeField] private Transform recordRoot;
[SerializeField] private GameObject recordPrefab;
#endregion
private readonly List<DialogText> _recordDataList = new();
// private RecordSource _recordSource;
public void Show()
{
@@ -65,18 +63,20 @@ namespace AibisDream.UI
private void ShowRecord()
{
var resource = new RecordSource(content, inactiveRoot, _recordDataList);
recordScroll.prefabSource = resource;
recordScroll.dataSource = resource;
recordScroll.totalCount = resource.TotalCount;
recordScroll.RefillCells();
for (var i = _recordDataList.Count - 1; i >= 0; i--)
{
var dialogText = _recordDataList[i];
var record = Instantiate(recordPrefab, recordRoot);
record.GetComponent<RecordItem>().Init(dialogText);
}
}
private void HideRecord()
{
content.DestroyAllChildren();
// TODO 可能有性能问题
recordRoot.DestroyAllChildren();
}
private void ReturnGame()
{
@@ -1,68 +0,0 @@
using System.Collections.Generic;
using AibisDream.Framework;
using AibisDream.Kit;
using AibisDream.Utility;
using UnityEngine;
namespace AibisDream.UI
{
public class RecordSource : ILoopScrollDataSource, ILoopScrollPrefabSource
{
private readonly SimpleObjectPool<RecordItem> _pool;
private readonly GameObject _itemPrefab;
private readonly Transform _contentRoot;
private readonly Transform _tempRoot;
private List<DialogText> _dialogTexts;
public int TotalCount => _dialogTexts.Count;
public RecordSource(Transform content, Transform tempRoot, List<DialogText> dialogTexts)
{
_contentRoot = content;
_tempRoot = tempRoot;
_dialogTexts = dialogTexts;
_itemPrefab = ResourceKit.LoadAssetSync<GameObject>(ConstRef.RecordPrefab);
_pool = new SimpleObjectPool<RecordItem>(InstantiateItem);
}
private RecordItem InstantiateItem()
{
return Object.Instantiate(_itemPrefab, _tempRoot).GetComponent<RecordItem>();
}
#region
public void ProvideData(Transform transform, int idx)
{
var item = transform.GetComponent<RecordItem>();
if (item != null)
{
item.Init(_dialogTexts[idx]);
}
}
public GameObject GetObject(int index)
{
var obj = _pool.Allocate().gameObject;
obj.transform.SetParent(_contentRoot);
return obj;
}
public void ReturnObject(Transform trans)
{
Debug.Log("return obj");
trans.SetParent(_tempRoot);
var record = trans.GetComponent<RecordItem>();
record.Dispose();
_pool.Recycle(record);
}
#endregion
}
}
@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 616a80ca37a1406e808457bc971323b1
timeCreated: 1757673398
+15 -97
View File
@@ -12,7 +12,6 @@ GameObject:
- component: {fileID: 6711119769030720946}
- component: {fileID: 1187987687030858387}
- component: {fileID: 1988114363986877782}
- component: {fileID: 6732491340423465413}
m_Layer: 5
m_Name: Line
m_TagString: Untagged
@@ -36,8 +35,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 795.00006, y: -102.205}
m_SizeDelta: {x: 900, y: 164.41}
m_AnchoredPosition: {x: 810, y: -74.005005}
m_SizeDelta: {x: 1000, y: 108.01}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6711119769030720946
CanvasRenderer:
@@ -72,7 +71,7 @@ MonoBehaviour:
Text
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: f242fb3dde1933640859f1c54591c9c8, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: -6659093157667844055, guid: f242fb3dde1933640859f1c54591c9c8, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
@@ -135,7 +134,7 @@ MonoBehaviour:
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 1
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!114 &1988114363986877782
@@ -152,46 +151,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_HorizontalFit: 0
m_VerticalFit: 2
--- !u!114 &6732491340423465413
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5004579197977972132}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 56eb0353ae6e5124bb35b17aff880f16, type: 3}
m_Name:
m_EditorClassIdentifier:
m_StringReference:
m_TableReference:
m_TableCollectionName:
m_TableEntryReference:
m_KeyId: 0
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
m_FormatArguments: []
m_UpdateString:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1187987687030858387}
m_TargetAssemblyTypeName: TMPro.TMP_Text, Unity.TextMeshPro
m_MethodName: set_text
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName:
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 1
references:
version: 2
RefIds: []
--- !u!1 &8132659264036482484
GameObject:
m_ObjectHideFlags: 0
@@ -203,7 +162,6 @@ GameObject:
- component: {fileID: 7590664592960692974}
- component: {fileID: 7520852388781276500}
- component: {fileID: 6005821570101327794}
- component: {fileID: 4623295846717124163}
m_Layer: 5
m_Name: ActorName
m_TagString: Untagged
@@ -227,8 +185,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 160, y: -40.11}
m_SizeDelta: {x: 300, y: 40.22}
m_AnchoredPosition: {x: 150, y: -40}
m_SizeDelta: {x: 260, y: 40}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7520852388781276500
CanvasRenderer:
@@ -261,7 +219,7 @@ MonoBehaviour:
m_text: New Text
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: f242fb3dde1933640859f1c54591c9c8, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: -6659093157667844055, guid: f242fb3dde1933640859f1c54591c9c8, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
@@ -324,49 +282,9 @@ MonoBehaviour:
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 1
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!114 &4623295846717124163
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8132659264036482484}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 56eb0353ae6e5124bb35b17aff880f16, type: 3}
m_Name:
m_EditorClassIdentifier:
m_StringReference:
m_TableReference:
m_TableCollectionName:
m_TableEntryReference:
m_KeyId: 0
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
m_FormatArguments: []
m_UpdateString:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 6005821570101327794}
m_TargetAssemblyTypeName: TMPro.TMP_Text, Unity.TextMeshPro
m_MethodName: set_text
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName:
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 1
references:
version: 2
RefIds: []
--- !u!1 &8643680592273313242
GameObject:
m_ObjectHideFlags: 0
@@ -395,7 +313,7 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8643680592273313242}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
@@ -407,7 +325,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 630.00006, y: 0}
m_SizeDelta: {x: 1260.0001, y: 204.41}
m_SizeDelta: {x: 1320, y: 148.01001}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &98892995500705291
CanvasRenderer:
@@ -446,7 +364,7 @@ MonoBehaviour:
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 6
m_PixelsPerUnitMultiplier: 3
--- !u!114 &4137042755979991823
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -460,7 +378,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 10
m_Left: 20
m_Right: 10
m_Top: 20
m_Bottom: 20
@@ -471,7 +389,7 @@ MonoBehaviour:
m_ChildControlWidth: 0
m_ChildControlHeight: 0
m_ChildScaleWidth: 0
m_ChildScaleHeight: 1
m_ChildScaleHeight: 0
m_ReverseArrangement: 0
--- !u!114 &567413764548442724
MonoBehaviour:
@@ -499,5 +417,5 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 0df5ddfccd99400d98c249484a3c8eb6, type: 3}
m_Name:
m_EditorClassIdentifier:
actorName: {fileID: 4623295846717124163}
dialogLine: {fileID: 6732491340423465413}
actorName: {fileID: 6005821570101327794}
dialogLine: {fileID: 1187987687030858387}