From db5fbb0cb837bb60d1dccc94e212900de547bb67 Mon Sep 17 00:00:00 2001 From: Ding Yuntian <1491671119@qq.com> Date: Mon, 25 May 2026 18:43:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(dialog):=20=E9=87=8D=E6=9E=84=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E5=B7=B2=E9=80=89=E7=8A=B6=E6=80=81=E8=A7=86=E8=A7=89?= =?UTF-8?q?=E8=A1=A8=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Prefabs/Bubbles/Dream Option.prefab | 80 +------------------ Assets/Scenes/Persistence.unity | 4 + Assets/Scripts/Dialog System/OptionView.cs | 44 +--------- .../UI/DialogUI/Options/DialogOption.cs | 18 +---- .../UI/DialogUI/Options/OnelineOption.cs | 11 ++- 5 files changed, 15 insertions(+), 142 deletions(-) diff --git a/Assets/Prefabs/Bubbles/Dream Option.prefab b/Assets/Prefabs/Bubbles/Dream Option.prefab index fdf41f58b..ff0206b56 100644 --- a/Assets/Prefabs/Bubbles/Dream Option.prefab +++ b/Assets/Prefabs/Bubbles/Dream Option.prefab @@ -143,7 +143,6 @@ MonoBehaviour: text: {fileID: 6343862642438606438} button: {fileID: 3624986506224747444} arrow: {fileID: 2138736795402918014} - selectedSign: {fileID: 994585125679848239} colorBlock: m_NormalColor: {r: 1, g: 1, b: 1, a: 1} m_HighlightedColor: {r: 0.4, g: 0.4, b: 0.4, a: 1} @@ -152,6 +151,7 @@ MonoBehaviour: m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} m_ColorMultiplier: 0 m_FadeDuration: 0 + selectedColor: {r: 0.5471698, g: 0.5471698, b: 0.5471698, a: 1} --- !u!114 &9163890225660695161 MonoBehaviour: m_ObjectHideFlags: 0 @@ -192,81 +192,6 @@ MonoBehaviour: m_EditorClassIdentifier: m_HorizontalFit: 2 m_VerticalFit: 0 ---- !u!1 &4507535836329041407 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2100970350256881776} - - component: {fileID: 2572548913308526007} - - component: {fileID: 994585125679848239} - m_Layer: 5 - m_Name: SelectSign - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!224 &2100970350256881776 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4507535836329041407} - 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 - m_Children: [] - m_Father: {fileID: 8909982681958940574} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 1, y: 0.5} - m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: 8, y: 0} - m_SizeDelta: {x: 16, y: 16} - m_Pivot: {x: 0, y: 0.5} ---- !u!222 &2572548913308526007 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4507535836329041407} - m_CullTransparentMesh: 1 ---- !u!114 &994585125679848239 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4507535836329041407} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 566787ba43e2a5646bdabb62bd6845f2, type: 3} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 --- !u!1 &4951730373337149047 GameObject: m_ObjectHideFlags: 0 @@ -372,8 +297,7 @@ RectTransform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 2100970350256881776} + m_Children: [] m_Father: {fileID: 1274478104802664553} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} diff --git a/Assets/Scenes/Persistence.unity b/Assets/Scenes/Persistence.unity index c2f4e6ac5..fe400857f 100644 --- a/Assets/Scenes/Persistence.unity +++ b/Assets/Scenes/Persistence.unity @@ -14667,6 +14667,10 @@ PrefabInstance: propertyPath: m_Name value: OnelineBox objectReference: {fileID: 0} + - target: {fileID: 8352794458094198668, guid: 60f4427b2070be04f90c1486bb86062c, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] diff --git a/Assets/Scripts/Dialog System/OptionView.cs b/Assets/Scripts/Dialog System/OptionView.cs index def71eb3f..542a15909 100644 --- a/Assets/Scripts/Dialog System/OptionView.cs +++ b/Assets/Scripts/Dialog System/OptionView.cs @@ -1,6 +1,5 @@ #nullable enable -using System.Collections.Generic; using System.Threading.Tasks; using AibisDream.Framework; using UnityEngine; @@ -10,7 +9,6 @@ namespace AibisDream { public class OptionView : DialoguePresenterBase { - private HashSet _selectedIds = new(); [SerializeField] private DefaultOptions defaultOptions; [SerializeField] private CenterOptions centerOptions; [SerializeField] private OnelineOptions onelineOptions; @@ -31,7 +29,6 @@ namespace AibisDream { return YarnTask.CompletedTask; } - public void LoadBubbles(BubbleSlotGroupData data) { defaultViewType = data.dialogViewType; @@ -44,7 +41,7 @@ namespace AibisDream var options = DialogOption.GeneOptions(dialogueOptions, optionId => { optionSelectedSource.TrySetResult(optionId); - }, _selectedIds); + }); var viewType = GetCurrentViewType(options); @@ -101,45 +98,6 @@ namespace AibisDream return optionViewType; } - // --------------------------- 生命周期方法 --------------------------- - - private void OnEnable() - { - RegisterEvent(); - } - - private void OnDisable() - { - UnRegisterEvent(); - } - - private void RegisterEvent() - { - // 进入游戏或者进入下一个Yarn的时候清空 - EnumEventSystem.Global.Register(GameLoopEnum.GameStart, ClearSelectedIds); - EnumEventSystem.Global.Register(EventEnum.NextYarn, ClearSelectedIds); - - // 选择选项的时候记录 - EnumEventSystem.Global.Register(DialogEventEnum.OptionSelected, RecordSelectedId); - } - - private void UnRegisterEvent() - { - EnumEventSystem.Global.UnRegister(GameLoopEnum.GameStart, ClearSelectedIds); - EnumEventSystem.Global.UnRegister(EventEnum.NextYarn, ClearSelectedIds); - EnumEventSystem.Global.UnRegister(DialogEventEnum.OptionSelected, RecordSelectedId); - } - - private void ClearSelectedIds() - { - _selectedIds.Clear(); - } - - private void RecordSelectedId(LineInfo lineInfo) - { - _selectedIds.Add(lineInfo.lineId); - } - public void HideDialog() { defaultOptions.HideOptions(); diff --git a/Assets/Scripts/UI/DialogUI/Options/DialogOption.cs b/Assets/Scripts/UI/DialogUI/Options/DialogOption.cs index 99eab351c..7818dd74e 100644 --- a/Assets/Scripts/UI/DialogUI/Options/DialogOption.cs +++ b/Assets/Scripts/UI/DialogUI/Options/DialogOption.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Collections.Generic; using AibisDream.Framework; @@ -15,7 +15,6 @@ namespace AibisDream private DialogueOption _option; public bool IsAvailable => _option.IsAvailable; - public bool IsSelected { get; private set; } public string Line => _option.Line.TextWithoutCharacterName.Text; public CharacterVo Character => _option.Line.GetCharacterVo(); @@ -51,21 +50,6 @@ namespace AibisDream return dialogueOptions .Select(item => new DialogOption { _option = item, _onOptionSelected = onOptionSelected }).ToArray(); } - - public static DialogOption[] GeneOptions(DialogueOption[] dialogueOptions, Action onOptionSelected, HashSet selectedIds) - { - var options = new List(); - foreach (var item in dialogueOptions) - { - var option = new DialogOption { _option = item, _onOptionSelected = onOptionSelected }; - if (selectedIds.Contains(option._option.TextID)) - { - option.IsSelected = true; - } - options.Add(option); - } - return options.ToArray(); - } } [Serializable] diff --git a/Assets/Scripts/UI/DialogUI/Options/OnelineOption.cs b/Assets/Scripts/UI/DialogUI/Options/OnelineOption.cs index 8b21df058..bf9ae8eab 100644 --- a/Assets/Scripts/UI/DialogUI/Options/OnelineOption.cs +++ b/Assets/Scripts/UI/DialogUI/Options/OnelineOption.cs @@ -11,11 +11,12 @@ namespace AibisDream [SerializeField] private TMP_Text text; [SerializeField] private BaseButton button; [SerializeField] private Image arrow; - [SerializeField] private Image selectedSign; [Header("颜色配置")] [SerializeField] private ColorBlock colorBlock; + [Header("已选择颜色")] + [SerializeField] private Color selectedColor; private DialogOption _option; public void Init() @@ -35,8 +36,6 @@ namespace AibisDream return; } - selectedSign.gameObject.SetActive(option.IsSelected); - text.SetText(option.Line); button.onClick.AddListener(() => { @@ -72,11 +71,15 @@ namespace AibisDream } } + private Color GetNormalColor() + { + return colorBlock.normalColor; + } + private void SetColor(Color color) { arrow.color = color; text.color = color; - selectedSign.color = color; } } } \ No newline at end of file