超大量的更新 修复很多问题,gameplay特效初步

This commit is contained in:
FloatGaming
2026-02-14 23:46:20 +08:00
parent ef8eb67259
commit 3a7a0b4669
360 changed files with 85670 additions and 4144 deletions
+107 -65
View File
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@@ -274,8 +274,7 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
var so = Instantiate(item);
data_List.Add(so);
// 每处理 5 个数据等待一帧,防止主线程卡死
if (i > 0 && i % 5 == 0)
// Documentation text normalized.
{
yield return null;
}
@@ -324,6 +323,13 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
{
return false;
}
if (panel == ui_Panel_Setting)
{
UI_SettingsPanelEnterAnim enterAnim = panel.GetComponent<UI_SettingsPanelEnterAnim>();
if (enterAnim == null)
enterAnim = panel.AddComponent<UI_SettingsPanelEnterAnim>();
enterAnim.enabled = true;
}
panel.SetActive(true);
return true;
}
@@ -334,7 +340,7 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
return;
}
selectScene_Loading = true;
// 使用异步加载场景,防止 GUI 冻结
// Documentation text normalized.
StartCoroutine(LoadSelectSceneAsync());
}
@@ -342,7 +348,7 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
{
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(ui_Select_Music_Scene_Name, LoadSceneMode.Single);
// 等待加载完成
// Documentation text normalized.
while (!asyncLoad.isDone)
{
yield return null;
@@ -362,6 +368,8 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
Setup_RightButtons_Hover();
Setup_Jiantou_Hover();
Fix_Button_Raycast();
Ensure_Character_Dialog_Controller();
StartCoroutine(Ensure_Character_Dialog_Controller_Delayed());
if (play_Enter_OnEnable)
{
Start_Enter_Routine();
@@ -371,6 +379,55 @@ public class UI_Panel_Main : Singleton_Mono<UI_Panel_Main>
Start_Jiantou_Loop();
}
}
IEnumerator Ensure_Character_Dialog_Controller_Delayed()
{
yield return null;
Ensure_Character_Dialog_Controller();
yield return null;
Ensure_Character_Dialog_Controller();
}
void Ensure_Character_Dialog_Controller()
{
Scene scene = SceneManager.GetActiveScene();
if (!scene.IsValid() || !string.Equals(scene.name, "UI_UI", StringComparison.OrdinalIgnoreCase))
{
return;
}
GameObject host = null;
Transform[] all = UnityEngine.Object.FindObjectsByType<Transform>(FindObjectsInactive.Include, FindObjectsSortMode.None);
for (int i = 0; i < all.Length; i++)
{
Transform t = all[i];
if (t == null || t.gameObject.scene != scene)
{
continue;
}
if (string.Equals(t.name, "__UICharacterDialogControllerHost", StringComparison.Ordinal))
{
host = t.gameObject;
break;
}
}
if (host == null)
{
host = new GameObject("__UICharacterDialogControllerHost");
try { SceneManager.MoveGameObjectToScene(host, scene); } catch { }
}
UI_CharacterDialogController controller = host.GetComponent<UI_CharacterDialogController>();
if (controller == null)
{
controller = host.AddComponent<UI_CharacterDialogController>();
}
if (!controller.enabled)
{
controller.enabled = true;
}
controller.RebindSoon();
}
void Fix_Button_Raycast()
{
if (!fix_Button_Raycast)
@@ -3234,15 +3291,17 @@ public class UI_RightButtonHover : MonoBehaviour, IPointerEnterHandler, IPointer
float textFlashInterval = 0.02f;
RectTransform imageRect;
Vector2 imageBasePos;
CanvasGroup imageGroup;
readonly List<CanvasGroup> textGroups = new();
Tween imageTween;
readonly List<Tween> textTweens = new();
public void ApplyConfig(float idleOffsetValue, float finalOffsetValue, float moveTimeValue, Ease moveEaseValue,
float textFlashTimeValue, int textFlashCountValue, float textFlashIntervalValue)
{
idleOffset = Mathf.Max(0f, idleOffsetValue);
finalOffset = finalOffsetValue;
// Keep icon inside the button frame: positive config means "shift left by this amount".
// Use a softened offset so icon sits slightly more to the right.
finalOffset = -Mathf.Abs(finalOffsetValue) * 0.75f;
moveTime = Mathf.Max(0.01f, moveTimeValue);
moveEase = moveEaseValue;
textFlashTime = Mathf.Max(0.01f, textFlashTimeValue);
@@ -3276,6 +3335,12 @@ public class UI_RightButtonHover : MonoBehaviour, IPointerEnterHandler, IPointer
if (imageRect != null)
{
imageBasePos = imageRect.anchoredPosition;
if (imageGroup == null)
{
imageGroup = imageRect.GetComponent<CanvasGroup>();
if (imageGroup == null)
imageGroup = imageRect.gameObject.AddComponent<CanvasGroup>();
}
}
textGroups.Clear();
for (int i = 0; i < transform.childCount; i++)
@@ -3318,32 +3383,36 @@ public class UI_RightButtonHover : MonoBehaviour, IPointerEnterHandler, IPointer
{
if (imageRect != null)
{
imageRect.anchoredPosition = imageBasePos + Vector2.left * idleOffset;
// Keep icon at its final position; only toggle visibility on hover.
imageRect.anchoredPosition = imageBasePos + Vector2.right * finalOffset;
}
if (imageGroup != null)
{
imageGroup.alpha = 0f; // hidden until hover
}
for (int i = 0; i < textGroups.Count; i++)
{
if (textGroups[i] != null)
{
textGroups[i].alpha = 0f;
// Text should always be visible (no flash-in).
textGroups[i].alpha = 1f;
}
}
}
public void OnPointerEnter(PointerEventData eventData)
{
MoveImage(true);
FlashTexts();
FlashImage();
}
public void OnPointerExit(PointerEventData eventData)
{
MoveImage(false);
HideTexts();
HideImage();
}
void MoveImage(bool toFinal)
void FlashImage()
{
if (imageRect == null)
if (imageRect == null || imageGroup == null)
{
return;
}
@@ -3352,69 +3421,42 @@ public class UI_RightButtonHover : MonoBehaviour, IPointerEnterHandler, IPointer
imageTween.Kill();
imageTween = null;
}
Vector2 target = toFinal
? imageBasePos + Vector2.right * finalOffset
: imageBasePos + Vector2.left * idleOffset;
imageTween = imageRect.DOAnchorPos(target, moveTime)
.SetEase(moveEase)
.SetUpdate(true);
}
void FlashTexts()
{
HideTexts();
for (int i = 0; i < textGroups.Count; i++)
{
CanvasGroup group = textGroups[i];
if (group == null)
{
continue;
}
group.alpha = 0f;
Sequence seq = DOTween.Sequence().SetUpdate(true);
for (int c = 0; c < textFlashCount; c++)
{
seq.Append(group.DOFade(1f, textFlashTime).SetEase(Ease.OutQuad));
seq.Append(group.DOFade(0f, textFlashTime).SetEase(Ease.InQuad));
if (textFlashInterval > 0f)
{
seq.AppendInterval(textFlashInterval);
}
}
seq.Append(group.DOFade(1f, textFlashTime).SetEase(Ease.OutQuad));
textTweens.Add(seq);
}
}
// Ensure icon is at its final position (no translation anim).
imageRect.anchoredPosition = imageBasePos + Vector2.right * finalOffset;
void HideTexts()
{
for (int i = 0; i < textTweens.Count; i++)
// Flash-in (blink) on hover, then stay visible.
imageGroup.alpha = 0f;
Sequence seq = DOTween.Sequence().SetUpdate(true);
for (int c = 0; c < textFlashCount; c++)
{
Tween tween = textTweens[i];
if (tween != null)
seq.Append(imageGroup.DOFade(1f, textFlashTime).SetEase(Ease.OutQuad));
seq.Append(imageGroup.DOFade(0f, textFlashTime).SetEase(Ease.InQuad));
if (textFlashInterval > 0f)
{
tween.Kill();
}
}
textTweens.Clear();
for (int i = 0; i < textGroups.Count; i++)
{
CanvasGroup group = textGroups[i];
if (group != null)
{
group.alpha = 0f;
seq.AppendInterval(textFlashInterval);
}
}
seq.Append(imageGroup.DOFade(1f, textFlashTime).SetEase(Ease.OutQuad));
imageTween = seq;
}
void KillTweens()
void HideImage()
{
if (imageTween != null)
{
imageTween.Kill();
imageTween = null;
}
HideTexts();
if (imageGroup != null)
{
imageGroup.alpha = 0f;
}
}
void KillTweens()
{
HideImage();
}
}
@@ -3603,7 +3645,7 @@ public class UI_StartButtonHover : MonoBehaviour, IPointerEnterHandler, IPointer
char[] filler = new char[remain];
for (int r = 0; r < remain; r++)
{
filler[r] = useDot ? '·' : randomChars[(i + r) % randomChars.Length];
filler[r] = useDot ? '' : randomChars[(i + r) % randomChars.Length];
}
suffix = new string(filler);
}