超大量的更新 修复很多问题,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
@@ -0,0 +1,114 @@
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;
public class UI_SelectSong_AutoPlayToggle : MonoBehaviour
{
[Header("Wiring")]
[SerializeField] private Button button;
[SerializeField] private Toggle toggle;
[SerializeField] private Image buttonImage;
[SerializeField] private Text labelText; // Text (Legacy)
[Header("Tween")]
[SerializeField] private float tweenDuration = 0.25f;
[SerializeField] private Ease tweenEase = Ease.OutCubic;
private static readonly Color32 OnBg = new Color32(0x3A, 0x3A, 0x3A, 0xFF);
private static readonly Color32 OffBg = new Color32(0xFF, 0xFF, 0xFF, 0xFF);
private static readonly Color32 OnText = new Color32(0xFF, 0xFF, 0xFF, 0xFF);
private static readonly Color32 OffText = new Color32(0x3A, 0x3A, 0x3A, 0xFF);
private void Awake()
{
TryAutoWire();
}
private void OnEnable()
{
TryAutoWire();
if (button != null)
{
button.onClick.RemoveListener(OnClick);
button.onClick.AddListener(OnClick);
}
if (toggle != null)
{
toggle.onValueChanged.RemoveListener(OnToggleChanged);
toggle.onValueChanged.AddListener(OnToggleChanged);
// Keep UI state consistent with global setting.
toggle.SetIsOnWithoutNotify(GameConfig.autoPlayEnabled);
}
ApplyVisual(GameConfig.autoPlayEnabled, instant: true);
}
private void OnDisable()
{
if (button != null)
{
button.onClick.RemoveListener(OnClick);
}
if (toggle != null)
{
toggle.onValueChanged.RemoveListener(OnToggleChanged);
}
KillTweens();
}
public void TryAutoWire()
{
button = button != null ? button : GetComponent<Button>();
toggle = toggle != null ? toggle : GetComponent<Toggle>();
buttonImage = buttonImage != null ? buttonImage : GetComponent<Image>();
if (buttonImage == null && toggle != null && toggle.targetGraphic is Image tgImage)
{
buttonImage = tgImage;
}
labelText = labelText != null ? labelText : GetComponentInChildren<Text>(true);
}
private void OnClick()
{
bool next = !GameConfig.autoPlayEnabled;
GameConfig.SetAutoPlayEnabled(next);
if (toggle != null)
{
toggle.SetIsOnWithoutNotify(next);
}
ApplyVisual(next, instant: false);
}
private void OnToggleChanged(bool isOn)
{
GameConfig.SetAutoPlayEnabled(isOn);
ApplyVisual(isOn, instant: false);
}
private void ApplyVisual(bool enabled, bool instant)
{
Color targetBg = enabled ? OnBg : OffBg;
Color targetText = enabled ? OnText : OffText;
if (instant || !Application.isPlaying || tweenDuration <= 0f)
{
if (buttonImage != null) buttonImage.color = targetBg;
if (labelText != null) labelText.color = targetText;
return;
}
KillTweens();
if (buttonImage != null)
buttonImage.DOColor(targetBg, tweenDuration).SetEase(tweenEase);
if (labelText != null)
labelText.DOColor(targetText, tweenDuration).SetEase(tweenEase);
}
private void KillTweens()
{
if (buttonImage != null) buttonImage.DOKill();
if (labelText != null) labelText.DOKill();
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f40014a25a3a82b48b992c7e80f41beb
@@ -0,0 +1,61 @@
using UnityEngine;
using UnityEngine.SceneManagement;
public static class UI_SelectSong_AutoPlayToggleBinder
{
private const string TargetSceneName = "selectYourSongFirst";
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void Init()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
SceneManager.sceneLoaded += OnSceneLoaded;
}
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (scene.name != TargetSceneName)
return;
TryBind(scene);
}
private static void TryBind(Scene scene)
{
// Ensure we have the latest persisted value (important when entering from editor play).
GameConfig.LoadPrefs();
// Prefer the user's specified hierarchy if present (active only).
GameObject go =
GameObject.Find("rightInfos/difficultyBtnInfos/difficultyBtnInfos/select_Auto") ??
GameObject.Find("rightInfos/difficultyBtnInfos/select_Auto");
if (go == null)
{
// Fallback: search by name in this scene (includes inactive objects).
var transforms = Object.FindObjectsByType<Transform>(FindObjectsInactive.Include, FindObjectsSortMode.None);
for (int i = 0; i < transforms.Length; i++)
{
var t = transforms[i];
if (t == null) continue;
if (t.gameObject.scene != scene) continue;
if (t.name != "select_Auto") continue;
go = t.gameObject;
break;
}
}
if (go == null)
{
if (GameConfig.verboseLogs)
Debug.LogWarning("[AutoPlay] select_Auto button not found in selectYourSongFirst scene. Autoplay toggle UI will be unavailable.");
return;
}
var toggle = go.GetComponent<UI_SelectSong_AutoPlayToggle>();
if (toggle == null)
toggle = go.AddComponent<UI_SelectSong_AutoPlayToggle>();
toggle.TryAutoWire();
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2d1187aab2506504fac07708ca18d940
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;
public class UI_SelectSong_EnterAnim : MonoBehaviour
{
@@ -20,6 +21,8 @@ public class UI_SelectSong_EnterAnim : MonoBehaviour
[SerializeField] float slideX = 180f;
[SerializeField] float slideY = 120f;
[SerializeField] float bgScaleFrom = 1.06f;
[SerializeField] bool useUnscaledTime = true;
[SerializeField] bool ensureVisibleOnComplete = true;
RectTransform root;
RectTransform bg;
@@ -83,7 +86,7 @@ public class UI_SelectSong_EnterAnim : MonoBehaviour
return;
}
bg = bg != null ? bg : FindRect(root, "BG");
bg = bg != null ? bg : FindPreferredSelectSceneBg();
leftDlc = leftDlc != null ? leftDlc : FindRect(root, "left_select_dlc");
songScroll = songScroll != null ? songScroll : FindRect(root, "SongScrollView");
rightInfos = rightInfos != null ? rightInfos : FindRect(root, "rightInfos");
@@ -130,6 +133,28 @@ public class UI_SelectSong_EnterAnim : MonoBehaviour
return null;
}
RectTransform FindPreferredSelectSceneBg()
{
// Prefer the scene root object named "bg" that owns a Canvas
// (the one shown in your hierarchy screenshot), not the legacy inactive "BG".
Transform[] all = Resources.FindObjectsOfTypeAll<Transform>();
for (int i = 0; i < all.Length; i++)
{
Transform t = all[i];
if (t == null) continue;
GameObject go = t.gameObject;
if (go == null || !go.scene.IsValid()) continue;
if (!string.Equals(t.name, "bg", System.StringComparison.OrdinalIgnoreCase)) continue;
if (go.GetComponent<Canvas>() == null) continue;
return t as RectTransform;
}
// Fallbacks for older scene hierarchy.
RectTransform fallback = FindRect(root, "BG");
if (fallback != null) return fallback;
return FindRect(root, "bg");
}
void CacheBase(RectTransform rect)
{
if (rect == null)
@@ -196,7 +221,7 @@ public class UI_SelectSong_EnterAnim : MonoBehaviour
void BuildSequence()
{
enterSeq = DOTween.Sequence();
enterSeq = DOTween.Sequence().SetUpdate(useUnscaledTime);
float t = delay;
if (bg != null && bg.gameObject.activeInHierarchy)
@@ -204,11 +229,11 @@ public class UI_SelectSong_EnterAnim : MonoBehaviour
CanvasGroup group = EnsureCanvasGroup(bg);
if (group != null)
{
enterSeq.Insert(t, group.DOFade(1f, panelTime).SetEase(ease));
enterSeq.Insert(t, group.DOFade(1f, panelTime).SetEase(ease).SetUpdate(useUnscaledTime));
}
if (baseScale.TryGetValue(bg, out Vector3 scale))
{
enterSeq.Insert(t, bg.DOScale(scale, panelTime).SetEase(ease));
enterSeq.Insert(t, bg.DOScale(scale, panelTime).SetEase(ease).SetUpdate(useUnscaledTime));
}
}
@@ -229,6 +254,11 @@ public class UI_SelectSong_EnterAnim : MonoBehaviour
InsertScale(enterDetail, t + 0.35f, buttonTime);
InsertScale(quickEnter, t + 0.38f, buttonTime);
if (ensureVisibleOnComplete)
{
enterSeq.OnComplete(SnapAllToVisibleFinalState);
}
}
void InsertSlide(RectTransform rect, float at, float time)
@@ -240,12 +270,12 @@ public class UI_SelectSong_EnterAnim : MonoBehaviour
CacheBase(rect);
if (basePos.TryGetValue(rect, out Vector2 pos))
{
enterSeq.Insert(at, rect.DOAnchorPos(pos, time).SetEase(ease));
enterSeq.Insert(at, rect.DOAnchorPos(pos, time).SetEase(ease).SetUpdate(useUnscaledTime));
}
CanvasGroup group = EnsureCanvasGroup(rect);
if (group != null)
{
enterSeq.Insert(at, group.DOFade(1f, time).SetEase(ease));
enterSeq.Insert(at, group.DOFade(1f, time).SetEase(ease).SetUpdate(useUnscaledTime));
}
}
@@ -258,12 +288,54 @@ public class UI_SelectSong_EnterAnim : MonoBehaviour
CacheBase(rect);
if (baseScale.TryGetValue(rect, out Vector3 scale))
{
enterSeq.Insert(at, rect.DOScale(scale, time).SetEase(ease));
enterSeq.Insert(at, rect.DOScale(scale, time).SetEase(ease).SetUpdate(useUnscaledTime));
}
CanvasGroup group = EnsureCanvasGroup(rect);
if (group != null)
{
enterSeq.Insert(at, group.DOFade(1f, time).SetEase(ease));
enterSeq.Insert(at, group.DOFade(1f, time).SetEase(ease).SetUpdate(useUnscaledTime));
}
}
void SnapAllToVisibleFinalState()
{
SnapVisible(bg, applyScale: true);
SnapVisible(leftDlc, applyScale: false);
SnapVisible(songScroll, applyScale: false);
SnapVisible(rightInfos, applyScale: false);
SnapVisible(songTitle, applyScale: false);
SnapVisible(dlcTitle, applyScale: false);
SnapVisible(quickEnter, applyScale: true);
SnapVisible(enterDetail, applyScale: true);
for (int i = 0; i < difficultyItems.Count; i++)
{
SnapVisible(difficultyItems[i], applyScale: false);
}
}
void SnapVisible(RectTransform rect, bool applyScale)
{
if (rect == null) return;
if (!rect.gameObject.activeSelf) rect.gameObject.SetActive(true);
CacheBase(rect);
if (basePos.TryGetValue(rect, out Vector2 pos))
{
rect.anchoredPosition = pos;
}
if (applyScale && baseScale.TryGetValue(rect, out Vector3 scale))
{
rect.localScale = scale;
}
CanvasGroup group = EnsureCanvasGroup(rect);
if (group != null)
{
group.alpha = 1f;
group.interactable = true;
group.blocksRaycasts = true;
}
}
@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
@@ -9,7 +9,7 @@ public class load_teammatesProfile : MonoBehaviour
private static bool heroCacheReady;
private static bool heroCacheBuilding;
[Header("½ÇɫͷÏñ")]
[Header("Inspector")]
public Image teammate_profile_01;
public Image teammate_profile_02;
public Image teammate_profile_03;