完善对话窗口的透明度设置

This commit is contained in:
SepComet 2026-02-12 21:11:20 +08:00
parent 306f40ad68
commit 57649da490
5 changed files with 62 additions and 7 deletions

View File

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using DataTable; using DataTable;
using Definition;
using Definition.Enum; using Definition.Enum;
using Event; using Event;
using GameFramework.DataTable; using GameFramework.DataTable;
@ -216,6 +217,8 @@ namespace CustomComponent
_formContext.DialogTitle = dialogRow.Title; _formContext.DialogTitle = dialogRow.Title;
_formContext.DialogUIMode = dialogRow.UIMode; _formContext.DialogUIMode = dialogRow.UIMode;
_formContext.PlayingSpeed = Mathf.Max(0f, _playingSpeed); _formContext.PlayingSpeed = Mathf.Max(0f, _playingSpeed);
_formContext.DialogWindowAlpha =
(DialogWindowAlpha)GameEntry.Setting.GetInt(Constant.Setting.DialogWindowAlpha);
_currentLineIndex = 0; _currentLineIndex = 0;
ApplyLineToContext(dialogLines[_currentLineIndex], _currentLineIndex, dialogLines.Count); ApplyLineToContext(dialogLines[_currentLineIndex], _currentLineIndex, dialogLines.Count);

View File

@ -10,6 +10,7 @@ using Sound;
using UI; using UI;
using UnityEngine; using UnityEngine;
using UnityEngine.Rendering; using UnityEngine.Rendering;
using UnityGameFramework.Runtime;
namespace Procedure namespace Procedure
@ -24,8 +25,12 @@ namespace Procedure
private const string SettingPrefix = "Setting."; private const string SettingPrefix = "Setting.";
private bool _gameStarted = false;
private void StartGame() private void StartGame()
{ {
if (_gameStarted) return;
_gameStarted = true;
} }
private void LoadGame() private void LoadGame()
@ -71,6 +76,9 @@ namespace Procedure
protected override void OnLeave(IFsm<IProcedureManager> procedureOwner, bool isShutdown) protected override void OnLeave(IFsm<IProcedureManager> procedureOwner, bool isShutdown)
{ {
_menuFormController?.CloseUI();
_settingFormController?.CloseUI();
var e = GameEntry.Event; var e = GameEntry.Event;
e.Unsubscribe(MenuStartEventArgs.EventId, MenuStart); e.Unsubscribe(MenuStartEventArgs.EventId, MenuStart);
e.Unsubscribe(MenuContinueEventArgs.EventId, MenuContinue); e.Unsubscribe(MenuContinueEventArgs.EventId, MenuContinue);
@ -85,6 +93,12 @@ namespace Procedure
float realElapseSeconds) float realElapseSeconds)
{ {
base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds); base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);
if (_gameStarted)
{
procedureOwner.SetData<VarInt32>("NextSceneId", (int)SceneId.GameplayA);
ChangeState<ProcedureChangeScene>(procedureOwner);
}
} }
#endregion #endregion
@ -94,11 +108,13 @@ namespace Procedure
private void MenuStart(object sender, GameEventArgs e) private void MenuStart(object sender, GameEventArgs e)
{ {
if (!(e is MenuStartEventArgs)) return; if (!(e is MenuStartEventArgs)) return;
StartGame();
} }
private void MenuContinue(object sender, GameEventArgs e) private void MenuContinue(object sender, GameEventArgs e)
{ {
if (!(e is MenuContinueEventArgs)) return; if (!(e is MenuContinueEventArgs)) return;
LoadGame();
} }
private void MenuSetting(object sender, GameEventArgs e) private void MenuSetting(object sender, GameEventArgs e)

View File

@ -22,5 +22,7 @@ namespace UI
public int LineIndex = -1; public int LineIndex = -1;
public int TotalLines = 0; public int TotalLines = 0;
public bool IsLastLine = false; public bool IsLastLine = false;
public DialogWindowAlpha DialogWindowAlpha = DialogWindowAlpha.Medium;
} }
} }

View File

@ -1,4 +1,6 @@
using DG.Tweening; using System.Collections.Generic;
using System.Linq;
using DG.Tweening;
using Definition.Enum; using Definition.Enum;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
@ -29,11 +31,14 @@ namespace UI
[SerializeField] private Ease _moveEase = Ease.OutCubic; [SerializeField] private Ease _moveEase = Ease.OutCubic;
[SerializeField] private Image[] _dialogBgImages;
private readonly int _singleSpeakerCenterPosition = Screen.width / 2; private readonly int _singleSpeakerCenterPosition = Screen.width / 2;
private string _leftSpeakerToken = string.Empty; private string _leftSpeakerToken = string.Empty;
private string _rightSpeakerToken = string.Empty; private string _rightSpeakerToken = string.Empty;
private Sequence _layoutSequence; private Sequence _layoutSequence;
private DialogWindowAlpha _currentWindowAlpha = DialogWindowAlpha.Medium;
public override void StartDialog(DialogFormContext context) public override void StartDialog(DialogFormContext context)
{ {
@ -45,6 +50,32 @@ namespace UI
_context = context; _context = context;
if (_context.DialogWindowAlpha != this._currentWindowAlpha)
{
_currentWindowAlpha = _context.DialogWindowAlpha;
float targetAlpha = _currentWindowAlpha switch
{
DialogWindowAlpha.None => 1,
DialogWindowAlpha.Low => 0.75f,
DialogWindowAlpha.Medium => 0.5f,
DialogWindowAlpha.High => 0.25f,
_ => 0.5f
};
if (_dialogBgImages.Length == 0)
{
//TODO:一个很奇怪的问题,在 prefab 里赋好的值实例化出来就没了,只能先这样赋值
_dialogBgImages = GetComponentsInChildren<Image>().Where(image => image.name == "bg").ToArray();
}
foreach (Image image in _dialogBgImages)
{
Color color = image.color;
color.a = targetAlpha;
image.color = color;
}
}
string speakerName = _context.SpeakerName; string speakerName = _context.SpeakerName;
if (_speakerArea != null) if (_speakerArea != null)

View File

@ -474,7 +474,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1} m_Color: {r: 1, g: 1, b: 1, a: 0.5019608}
m_RaycastTarget: 0 m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1 m_Maskable: 1
@ -586,7 +586,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 0.39215687, g: 0.39215687, b: 0.39215687, a: 0.39215687} m_Color: {r: 0.39215687, g: 0.39215687, b: 0.39215687, a: 0.5019608}
m_RaycastTarget: 0 m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1 m_Maskable: 1
@ -664,6 +664,9 @@ MonoBehaviour:
_rightSpritePosition: -450 _rightSpritePosition: -450
_moveDuration: 0.25 _moveDuration: 0.25
_moveEase: 9 _moveEase: 9
_dialogBgImages:
- {fileID: 7254061520918156868}
- {fileID: 8566667250576683572}
--- !u!1 &6371466324854950042 --- !u!1 &6371466324854950042
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0