屏幕问题

This commit is contained in:
2025-02-13 20:53:28 +08:00
parent 94e01a9baa
commit 496f538b9f
41 changed files with 507 additions and 265 deletions
@@ -3,7 +3,6 @@ using System.Collections;
using AibisDream.Framework;
using AibisDream.Kit;
using DG.Tweening;
using Febucci.UI;
using TMPro;
using UnityEngine;
@@ -16,6 +15,7 @@ namespace AibisDream.FixSystem
#region
public float rotateDuration = 0.5f;
public float typeSpeed = 0.05f;
#endregion
@@ -24,7 +24,6 @@ namespace AibisDream.FixSystem
private Transform _textScreen;
[SerializeField] private TMP_Text title;
[SerializeField] private TMP_Text text;
[SerializeField] private TypewriterByCharacter textTypewriter;
[SerializeField] private SpriteRenderer screenImage;
private Material _imageMaterial;
@@ -49,8 +48,6 @@ namespace AibisDream.FixSystem
{
FixSystemCenter.SystemDic.Register(this);
DialogCanvasManager.Instance.RegisterDialogView(DialogViewType.Screen, this);
textTypewriter.onTextShowed.AddListener(() => StartCoroutine(AutoNextStep()));
}
private void OnDestroy()
@@ -72,19 +69,28 @@ namespace AibisDream.FixSystem
title.text = targetTitle;
}
public void ShowText(string targetText)
public IEnumerator ShowText(string targetText)
{
// 获取旧文字
// 先换行
if (!string.IsNullOrEmpty(text.text))
{
text.text += "\n";
}
var oldText = text.text;
// if (!string.IsNullOrWhiteSpace(oldText))
// {
// // 去掉notype标签,并且加上新的
// var rawOldText = oldText.Replace("<notype>", "").Replace("</notype>", "");
// oldText = "<notype> " + rawOldText + " </notype>";
// }
// 显示文字
textTypewriter.ShowText(oldText + targetText);
var targetLength = text.text.Length + targetText.Length;
// 逐个字符添加
yield return DOTween.To(() => text.text.Length, x => UpdateText(x, targetText, oldText), targetLength,
targetText.Length * typeSpeed).WaitForCompletion();
yield return new WaitForSeconds(0.5f);
_nextStep.Invoke();
}
private void UpdateText(int currentLength, string nextText, string oldText)
{
var appendLength = currentLength - oldText.Length;
text.text = oldText + nextText[..appendLength];
}
public Tween ShowImage(Sprite sprite)
@@ -133,7 +139,7 @@ namespace AibisDream.FixSystem
// 右侧加载图片
var tween = ShowImage(sprite);
yield return tween.WaitForCompletion();
// 左侧打开副屏
OpenTextScreen();
yield return new WaitForSeconds(rotateDuration + 0.2f);
@@ -151,7 +157,7 @@ namespace AibisDream.FixSystem
// 左侧回收屏幕
CloseTextScreen();
yield return new WaitForSeconds(rotateDuration + 0.2f);
EnumEventSystem.Global.Send(EventEnum.CloseScreen);
}
@@ -163,8 +169,7 @@ namespace AibisDream.FixSystem
bool isAutoSkip = false)
{
ShowTitle(character.GetActorName());
ShowText(dialogLine);
StartCoroutine(ShowText(dialogLine));
// 每行自动跳过
_nextStep = nextStep;
}
@@ -190,13 +195,6 @@ namespace AibisDream.FixSystem
// 这里不能手动跳到下一行
}
private IEnumerator AutoNextStep()
{
yield return new WaitForSeconds(0.2f);
_nextStep?.Invoke();
_nextStep = null;
}
#endregion
}
@@ -212,7 +210,7 @@ namespace AibisDream.FixSystem
void ShowTitle(string title);
// 显示正文
void ShowText(string text);
IEnumerator ShowText(string text);
// 显示图片
Tween ShowImage(Sprite sprite);