perf
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.UI
|
||||
@@ -21,24 +22,42 @@ namespace Ichni.UI
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeIn(float duration = 0.5f)
|
||||
public void FadeIn(float duration = 0.5f, bool ignoreTimeScale = false, UnityAction action = null)
|
||||
{
|
||||
mainCanvasGroup.gameObject.SetActive(true);
|
||||
mainCanvasGroup.DOFade(1f, duration).OnComplete(() =>
|
||||
|
||||
Tweener fade = mainCanvasGroup.DOFade(1f, duration).OnComplete(() =>
|
||||
{
|
||||
mainCanvasGroup.interactable = true;
|
||||
mainCanvasGroup.blocksRaycasts = true;
|
||||
}).Play();
|
||||
action?.Invoke();
|
||||
});
|
||||
|
||||
if (ignoreTimeScale)
|
||||
{
|
||||
fade.SetUpdate(true);
|
||||
}
|
||||
|
||||
fade.Play();
|
||||
}
|
||||
|
||||
public void FadeOut(float duration = 0.5f)
|
||||
public void FadeOut(float duration = 0.5f, bool ignoreTimeScale = false, UnityAction action = null)
|
||||
{
|
||||
mainCanvasGroup.interactable = false;
|
||||
mainCanvasGroup.blocksRaycasts = false;
|
||||
mainCanvasGroup.DOFade(0f, duration).OnComplete(() =>
|
||||
|
||||
Tweener fade = mainCanvasGroup.DOFade(0f, duration).OnComplete(() =>
|
||||
{
|
||||
action?.Invoke();
|
||||
mainCanvasGroup.gameObject.SetActive(false);
|
||||
}).Play();
|
||||
});
|
||||
|
||||
if (ignoreTimeScale)
|
||||
{
|
||||
fade.SetUpdate(true);
|
||||
}
|
||||
|
||||
fade.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,8 +27,7 @@ namespace Ichni.UI
|
||||
{
|
||||
public void SetUpPrepareUIPage(string songName)
|
||||
{
|
||||
chapter = ChapterSelectionManager.instance.chapters
|
||||
.FirstOrDefault(c => c.chapterIndex == ChapterSelectionManager.instance.currentChapter);
|
||||
chapter = ChapterSelectionManager.instance.currentChapter;
|
||||
songItem = chapter.songs.FirstOrDefault(s => s.songName == songName);
|
||||
|
||||
this.songName = songName;
|
||||
@@ -60,16 +59,8 @@ namespace Ichni.UI
|
||||
|
||||
public void EnterGame()
|
||||
{
|
||||
InformationTransistor.instance.SetInformation(
|
||||
ChapterSelectionManager.instance.currentChapter,
|
||||
songItem.songName,
|
||||
songItem.composer,
|
||||
difficultyName,
|
||||
songItem.illustratorName,
|
||||
difficultyData.displayDifficultyName,
|
||||
difficultyData.color, songItem.albumIllustrationCover,
|
||||
chapter.chapterSwitch, songItem.songSwitch);
|
||||
|
||||
InformationTransistor.instance.SetInformation(ChapterSelectionManager.instance.currentChapter, songItem, difficultyData);
|
||||
MenuAudioManager.instance.audioContainer.StopEvent("PlayPreview");
|
||||
MenuManager.instance.TestEnterGame();
|
||||
}
|
||||
}
|
||||
|
||||
107
Assets/Scripts/UI/SongSelection/DifficultySelectionButton.cs
Normal file
107
Assets/Scripts/UI/SongSelection/DifficultySelectionButton.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DG.Tweening;
|
||||
using Sirenix.OdinInspector;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Menu.UI
|
||||
{
|
||||
public partial class DifficultySelectionButton : MonoBehaviour
|
||||
{
|
||||
private DifficultySelectionContainer container => MenuManager.instance.songSelectionUIPage.difficultySelectionContainer;
|
||||
|
||||
public Button button;
|
||||
public DifficultyData difficultyData;
|
||||
|
||||
public TMP_Text difficultyValueText;
|
||||
public TMP_Text difficultyNameText;
|
||||
|
||||
public Sprite selectedSprite;
|
||||
public Sprite unselectedSprite;
|
||||
|
||||
[Title("Parts")]
|
||||
public Image background;
|
||||
public Image innerRing;
|
||||
public Image outerRing;
|
||||
public Image star;
|
||||
public Image upperLeftCorner;
|
||||
public Image lowerLeftCorner;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
button.onClick.AddListener(Select);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class DifficultySelectionButton
|
||||
{
|
||||
public void SetUp(DifficultyData difficulty)
|
||||
{
|
||||
this.difficultyData = difficulty;
|
||||
difficultyValueText.text = difficulty.difficultyValue.ToString();
|
||||
difficultyNameText.text = difficulty.GetDifficultyName();
|
||||
}
|
||||
|
||||
private Sequence seq;
|
||||
|
||||
public void Select()
|
||||
{
|
||||
MenuManager.instance.songSelectionUIPage.selectedDifficulty = difficultyData;
|
||||
MenuManager.instance.songSelectionUIPage.songInfoUI.SetCharter(difficultyData.charterName);
|
||||
|
||||
if(container.selectedButton == this) return;
|
||||
|
||||
MenuManager.instance.songSelectionUIPage.difficultySelectionContainer.selectedButton?.Deselect();
|
||||
MenuManager.instance.songSelectionUIPage.difficultySelectionContainer.selectedButton = this;
|
||||
MenuManager.instance.songSelectionUIPage.currentSelectedDifficultyIndex = difficultyData.difficultyIndex;
|
||||
|
||||
seq?.Kill(true);
|
||||
background.sprite = selectedSprite;
|
||||
|
||||
seq = DOTween.Sequence();
|
||||
seq.Append(background.rectTransform.DOAnchorPosX(-7.5f, 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(background.rectTransform.DOSizeDelta(new Vector2(85, 85), 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(background.DOColor(difficultyData.color, 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(innerRing.rectTransform.DOScale(Vector3.one, 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(innerRing.rectTransform.DOLocalRotate(Vector3.zero, 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(outerRing.rectTransform.DOScale(Vector3.one, 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(outerRing.rectTransform.DOLocalRotate(Vector3.zero, 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(star.rectTransform.DOAnchorPosX(-55, 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(star.rectTransform.DOScale(Vector3.one, 0.4f).SetEase(Ease.OutQuart));
|
||||
|
||||
seq.Append(upperLeftCorner.rectTransform.DOScale(Vector3.one, 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(upperLeftCorner.rectTransform.DOAnchorPos(new Vector2(-52, 52), 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(lowerLeftCorner.rectTransform.DOScale(Vector3.one, 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(lowerLeftCorner.rectTransform.DOAnchorPos(new Vector2(-52, -52), 0.4f).SetEase(Ease.OutQuart));
|
||||
|
||||
seq.Play();
|
||||
}
|
||||
|
||||
public void Deselect()
|
||||
{
|
||||
seq?.Kill(true);
|
||||
background.sprite = unselectedSprite;
|
||||
background.color = Color.white;
|
||||
|
||||
seq = DOTween.Sequence();
|
||||
seq.Append(upperLeftCorner.rectTransform.DOScale(Vector3.zero, 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(upperLeftCorner.rectTransform.DOAnchorPos(Vector2.zero,0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(lowerLeftCorner.rectTransform.DOScale(Vector3.zero, 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(lowerLeftCorner.rectTransform.DOAnchorPos(Vector2.zero, 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(background.rectTransform.DOAnchorPosX(0f, 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(background.rectTransform.DOSizeDelta(new Vector2(100, 100), 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(innerRing.rectTransform.DOScale(Vector3.zero, 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(innerRing.rectTransform.DOLocalRotate(new Vector3(0, 0, 180), 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(outerRing.rectTransform.DOScale(Vector3.zero, 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(outerRing.rectTransform.DOLocalRotate(new Vector3(0, 0, -180), 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(star.rectTransform.DOScale(Vector3.zero, 0.4f).SetEase(Ease.OutQuart));
|
||||
seq.Join(star.rectTransform.DOAnchorPosX(0, 0.4f).SetEase(Ease.OutQuart));
|
||||
|
||||
seq.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 189122ac264c56d4f875e162820a412b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.Menu.UI
|
||||
{
|
||||
public class DifficultySelectionContainer : MonoBehaviour
|
||||
{
|
||||
public List<DifficultySelectionButton> buttons;
|
||||
public DifficultySelectionButton selectedButton;
|
||||
|
||||
public void SetUp(List<DifficultyData> difficulties)
|
||||
{
|
||||
int difficultyCount = difficulties.Count;
|
||||
|
||||
for (var i = 0; i < buttons.Count; i++)
|
||||
{
|
||||
buttons[i].gameObject.SetActive(i < difficultyCount);
|
||||
}
|
||||
|
||||
for (int i = 0; i < difficultyCount; i++)
|
||||
{
|
||||
buttons[i].SetUp(difficulties[i]);
|
||||
}
|
||||
|
||||
if (MenuManager.instance.songSelectionUIPage.currentSelectedDifficultyIndex >= difficultyCount)
|
||||
{
|
||||
MenuManager.instance.songSelectionUIPage.currentSelectedDifficultyIndex = difficultyCount - 1;
|
||||
}
|
||||
|
||||
buttons[MenuManager.instance.songSelectionUIPage.currentSelectedDifficultyIndex].Select();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f231d99b2fba2144aad5f597a7dc88f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
45
Assets/Scripts/UI/SongSelection/PlaySongUI.cs
Normal file
45
Assets/Scripts/UI/SongSelection/PlaySongUI.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Menu.UI
|
||||
{
|
||||
public class PlaySongUI : MonoBehaviour
|
||||
{
|
||||
public Button enterGameButton;
|
||||
public List<RectTransform> arrows;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
enterGameButton.onClick.AddListener(EnterGame);
|
||||
}
|
||||
|
||||
private void EnterGame()
|
||||
{
|
||||
InformationTransistor.instance.SetInformation(
|
||||
ChapterSelectionManager.instance.currentChapter,
|
||||
MenuManager.instance.songSelectionUIPage.selectedSong,
|
||||
MenuManager.instance.songSelectionUIPage.selectedDifficulty);
|
||||
MenuAudioManager.instance.audioContainer.StopEvent("PlayPreview");
|
||||
|
||||
DOTween.KillAll();
|
||||
|
||||
Sequence arrowSeq = DOTween.Sequence();
|
||||
|
||||
foreach (var arrow in arrows)
|
||||
{
|
||||
arrowSeq.Join(arrow.DOAnchorPosX(-584.5f, 0.2f));
|
||||
}
|
||||
|
||||
arrowSeq.OnComplete(() =>
|
||||
{
|
||||
MenuManager.instance.TestEnterGame();
|
||||
});
|
||||
|
||||
arrowSeq.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/SongSelection/PlaySongUI.cs.meta
Normal file
11
Assets/Scripts/UI/SongSelection/PlaySongUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6486742262fada848bc32ab015d46ac3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
28
Assets/Scripts/UI/SongSelection/SongInfoUI.cs
Normal file
28
Assets/Scripts/UI/SongSelection/SongInfoUI.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Menu.UI
|
||||
{
|
||||
public class SongInfoUI : MonoBehaviour
|
||||
{
|
||||
public Image illustration;
|
||||
public TMP_Text charterNameText;
|
||||
public TMP_Text illustratorText;
|
||||
|
||||
public TMP_Text accuracyText;
|
||||
|
||||
public void SetIllustration(Sprite cover, string illustratorName)
|
||||
{
|
||||
illustration.sprite = cover;
|
||||
illustratorText.text = illustratorName;
|
||||
}
|
||||
|
||||
public void SetCharter(string charterName)
|
||||
{
|
||||
charterNameText.text = charterName == string.Empty ? "Unknown Charter" : charterName;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/SongSelection/SongInfoUI.cs.meta
Normal file
11
Assets/Scripts/UI/SongSelection/SongInfoUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a4362e42f4fc1e4da4bb2db5eb1a8e6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -12,18 +12,15 @@ namespace Ichni.Menu.UI
|
||||
public class SongListControllerUI : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
|
||||
{
|
||||
[Title("核心组件")]
|
||||
[SerializeField] private RectTransform content;
|
||||
[SerializeField] private RectTransform viewport;
|
||||
[SerializeField] public RectTransform content;
|
||||
[SerializeField] public RectTransform viewport;
|
||||
|
||||
[Title("预制体")]
|
||||
[SerializeField]
|
||||
private GameObject songItemPrefab;
|
||||
[Title("【临时】测试用标题列表")]
|
||||
[SerializeField]
|
||||
private List<string> songTitles;
|
||||
|
||||
[Title("对齐与动画")]
|
||||
[SerializeField] private RectTransform centerPoint;
|
||||
[SerializeField] public RectTransform centerPoint;
|
||||
[SerializeField] private float snapSpeed = 5f;
|
||||
[SerializeField] private float decelerationRate = 0.135f;
|
||||
|
||||
@@ -37,7 +34,7 @@ namespace Ichni.Menu.UI
|
||||
[Tooltip("当松手时的速度大于此值,才会被判定为一次“甩动”并产生惯性")]
|
||||
[SerializeField] private float flickThreshold = 50f;
|
||||
|
||||
public SongSelectionTabUI selectedTab;
|
||||
public SongSelectionTab selectedTab;
|
||||
|
||||
// 内部变量
|
||||
private List<RectTransform> songItems = new List<RectTransform>();
|
||||
@@ -110,11 +107,10 @@ namespace Ichni.Menu.UI
|
||||
|
||||
public void GenerateSongTabs()
|
||||
{
|
||||
string chapter = ChapterSelectionManager.instance.currentChapter;
|
||||
ChapterSelectionUnit chapterUnit = ChapterSelectionManager.instance.chapters.Find(c => c.chapterIndex == chapter);
|
||||
ChapterSelectionUnit chapterUnit = ChapterSelectionManager.instance.currentChapter;
|
||||
foreach (SongItemData song in chapterUnit.songs)
|
||||
{
|
||||
SongSelectionTabUI tab = Instantiate(songItemPrefab ,content).GetComponent<SongSelectionTabUI>();
|
||||
SongSelectionTab tab = Instantiate(songItemPrefab ,content).GetComponent<SongSelectionTab>();
|
||||
songItems.Add(tab.GetComponent<RectTransform>());
|
||||
tab.SetUpTab(song);
|
||||
}
|
||||
@@ -131,8 +127,8 @@ namespace Ichni.Menu.UI
|
||||
selectedTab?.SetSelection(false);
|
||||
selectedTab = null; // 清除当前选中的Tab
|
||||
|
||||
DOTween.To(x=>targetX = x, targetX, -1600f, 0.2f).SetEase(Ease.OutQuad).Play();
|
||||
songItems.ForEach(item => item.DOScale(1.2f,0.2f).SetEase(Ease.OutQuad).Play());
|
||||
//DOTween.To(x=>targetX = x, targetX, -1550f, 0.2f).SetEase(Ease.OutQuad).Play();
|
||||
//songItems.ForEach(item => item.DOScale(1.1f,0.2f).SetEase(Ease.OutQuad).Play());
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
@@ -147,8 +143,8 @@ namespace Ichni.Menu.UI
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
isDragging = false;
|
||||
DOTween.To(x => targetX = x, targetX, -1500f, 0.2f).SetEase(Ease.OutQuad).Play();
|
||||
songItems.ForEach(item => item.DOScale(1,0.2f).SetEase(Ease.OutQuad).Play());
|
||||
//DOTween.To(x => targetX = x, targetX, -1500f, 0.2f).SetEase(Ease.OutQuad).Play();
|
||||
//songItems.ForEach(item => item.DOScale(1,0.2f).SetEase(Ease.OutQuad).Play());
|
||||
|
||||
// 【核心修正】在这里根据速度决定下一步做什么
|
||||
if (Mathf.Abs(velocity.y) > flickThreshold)
|
||||
@@ -193,18 +189,10 @@ namespace Ichni.Menu.UI
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator SnapToTab(SongSelectionTabUI tab)
|
||||
public IEnumerator SnapToTab(SongSelectionTab tab)
|
||||
{
|
||||
selectedTab?.SetSelection(false);
|
||||
selectedTab = null; // 清除当前选中的Tab
|
||||
|
||||
DOTween.To(x=>targetX = x, targetX, -1600f, 0.2f).SetEase(Ease.OutQuad).Play();
|
||||
songItems.ForEach(item => item.DOScale(1.2f,0.2f).SetEase(Ease.OutQuad).Play());
|
||||
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
DOTween.To(x => targetX = x, targetX, -1500f, 0.2f).SetEase(Ease.OutQuad).Play();
|
||||
songItems.ForEach(item => item.DOScale(1,0.2f).SetEase(Ease.OutQuad).Play());
|
||||
|
||||
yield return StartCoroutine(SnapToItem(tab.GetComponent<RectTransform>(), false));
|
||||
}
|
||||
@@ -217,7 +205,14 @@ namespace Ichni.Menu.UI
|
||||
}
|
||||
|
||||
Debug.Log("开始对齐到: " + targetItem.name);
|
||||
|
||||
|
||||
selectedTab = targetItem.GetComponent<SongSelectionTab>();
|
||||
selectedTab.SetSelection(true);
|
||||
|
||||
SongItemData connectedSong = selectedTab.connectedSong;
|
||||
MenuManager.instance.songSelectionUIPage.selectedSong = connectedSong;
|
||||
|
||||
|
||||
Vector3 closestItemLocalPos = viewport.InverseTransformPoint(targetItem.position);
|
||||
Vector3 centerPointLocalPos = viewport.InverseTransformPoint(centerPoint.position);
|
||||
float localOffsetY = centerPointLocalPos.y - closestItemLocalPos.y;
|
||||
@@ -249,8 +244,10 @@ namespace Ichni.Menu.UI
|
||||
}
|
||||
|
||||
Debug.Log($"已对齐到: {targetItem.name}");
|
||||
selectedTab = targetItem.GetComponent<SongSelectionTabUI>();
|
||||
selectedTab.SetSelection(true);
|
||||
selectedTab.SetPreview();
|
||||
|
||||
MenuManager.instance.songSelectionUIPage.difficultySelectionContainer.SetUp(connectedSong.difficultyDataList);
|
||||
MenuManager.instance.songSelectionUIPage.songInfoUI.SetIllustration(connectedSong.illustration, connectedSong.illustratorName);
|
||||
}
|
||||
}
|
||||
}
|
||||
94
Assets/Scripts/UI/SongSelection/SongSelectionTab.cs
Normal file
94
Assets/Scripts/UI/SongSelection/SongSelectionTab.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using Sirenix.OdinInspector;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Menu.UI
|
||||
{
|
||||
public partial class SongSelectionTab : MonoBehaviour
|
||||
{
|
||||
private SongListControllerUI songListController => MenuManager.instance.songSelectionUIPage.songListController;
|
||||
|
||||
public SongItemData connectedSong;
|
||||
public TMP_Text songNameText;
|
||||
|
||||
public Button quickSwitchButton;
|
||||
|
||||
public float distanceToCenter;
|
||||
|
||||
[Title("背景图&选中处理")]
|
||||
public RectTransform background;
|
||||
public Image selectedImage;
|
||||
public Image unselectedImage;
|
||||
|
||||
public void SetUpTab(SongItemData song)
|
||||
{
|
||||
connectedSong = song;
|
||||
songNameText.text = song.songName;
|
||||
|
||||
quickSwitchButton.onClick.AddListener(() =>
|
||||
{
|
||||
if (MenuManager.instance.songSelectionUIPage.songListController.selectedTab == this)
|
||||
{
|
||||
// MenuManager.instance.prepareUIPage.SetUpPrepareUIPage(song.songName);
|
||||
// MenuManager.instance.prepareUIPage.FadeIn();
|
||||
}
|
||||
else
|
||||
{
|
||||
StartCoroutine(MenuManager.instance.songSelectionUIPage.songListController.SnapToTab(this));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
RectTransform centerPoint = songListController.centerPoint;
|
||||
RectTransform rectTransform = GetComponent<RectTransform>();
|
||||
|
||||
distanceToCenter = Mathf.Abs(centerPoint.position.y - rectTransform.position.y);
|
||||
float x1 = Mathf.Sqrt(distanceToCenter) * 25 + 25;
|
||||
float x2 = distanceToCenter * 5 + 25;
|
||||
float x3 = Mathf.Pow(distanceToCenter, 2) / 10f + 25;
|
||||
rectTransform.GetChild(0).GetComponent<RectTransform>().anchoredPosition = new Vector2(x2, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class SongSelectionTab
|
||||
{
|
||||
public void SetSelection(bool isSelected)
|
||||
{
|
||||
if (isSelected)
|
||||
{
|
||||
background.DOScaleY(1.2f, 0.25f)
|
||||
.SetEase(Ease.OutQuad)
|
||||
.Play();
|
||||
|
||||
selectedImage.DOFade(1, 0.25f)
|
||||
.SetEase(Ease.OutQuad)
|
||||
.Play();
|
||||
}
|
||||
else
|
||||
{
|
||||
background.DOScaleY(1f, 0.25f)
|
||||
.SetEase(Ease.OutQuad)
|
||||
.Play();
|
||||
|
||||
selectedImage.DOFade(0, 0.25f)
|
||||
.SetEase(Ease.OutQuad)
|
||||
.Play();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPreview()
|
||||
{
|
||||
MenuAudioManager.instance.audioContainer.StopEvent("PlayPreview");
|
||||
MenuAudioManager.instance.audioContainer.SetSwitch(connectedSong.songSwitch);
|
||||
MenuAudioManager.instance.audioContainer.PostEvent("PlayPreview");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using Sirenix.OdinInspector;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Menu.UI
|
||||
{
|
||||
public partial class SongSelectionTabUI : MonoBehaviour
|
||||
{
|
||||
public SongItemData connectedSong;
|
||||
public TMP_Text songNameText;
|
||||
public Button switchDifficultyButton;
|
||||
public Button previewButton;
|
||||
public Button startSongButton;
|
||||
public string currentDifficultyName;
|
||||
|
||||
[Title("背景图&选中处理")]
|
||||
public Image backgroundImage;
|
||||
public Sprite unselectedSprite;
|
||||
public Sprite selectedSprite;
|
||||
|
||||
public void SetUpTab(SongItemData song)
|
||||
{
|
||||
connectedSong = song;
|
||||
songNameText.text = song.songName;
|
||||
currentDifficultyName = song.difficultyDataList[0].difficultyName;
|
||||
switchDifficultyButton.GetComponentInChildren<TMP_Text>().text = currentDifficultyName + " Lv." + song.difficultyDataList[0].difficultyValue;
|
||||
switchDifficultyButton.GetComponentInChildren<TMP_Text>().color = song.difficultyDataList[0].color;
|
||||
|
||||
switchDifficultyButton.onClick.AddListener(() =>
|
||||
{
|
||||
int currentIndex = song.difficultyDataList.FindIndex(d => d.difficultyName == currentDifficultyName);
|
||||
int nextIndex = (currentIndex + 1) % song.difficultyDataList.Count;
|
||||
currentDifficultyName = song.difficultyDataList[nextIndex].difficultyName;
|
||||
|
||||
switchDifficultyButton.GetComponentInChildren<TMP_Text>().text = currentDifficultyName + " Lv." + song.difficultyDataList[nextIndex].difficultyValue;
|
||||
switchDifficultyButton.GetComponentInChildren<TMP_Text>().color = song.difficultyDataList[nextIndex].color;
|
||||
});
|
||||
|
||||
previewButton.onClick.AddListener(() =>
|
||||
{
|
||||
MenuAudioManager.instance.audioContainer.StopEvent("PlayPreview");
|
||||
MenuAudioManager.instance.audioContainer.SetSwitch(connectedSong.songSwitch);
|
||||
MenuAudioManager.instance.audioContainer.PostEvent("PlayPreview");
|
||||
});
|
||||
|
||||
startSongButton.onClick.AddListener(() =>
|
||||
{
|
||||
if (MenuManager.instance.songSelectionUIPage.songListController.selectedTab == this)
|
||||
{
|
||||
MenuManager.instance.prepareUIPage.SetUpPrepareUIPage(song.songName);
|
||||
MenuManager.instance.prepareUIPage.FadeIn();
|
||||
}
|
||||
else
|
||||
{
|
||||
StartCoroutine(MenuManager.instance.songSelectionUIPage.songListController.SnapToTab(this));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public partial class SongSelectionTabUI
|
||||
{
|
||||
public void SetSelection(bool isSelected)
|
||||
{
|
||||
backgroundImage.sprite = isSelected ? selectedSprite : unselectedSprite;
|
||||
if (isSelected)
|
||||
{
|
||||
GetComponent<RectTransform>().DOScale(1.2f, 0.2f).SetEase(Ease.OutQuad).Play();
|
||||
GetComponent<RectTransform>().GetChild(0).GetComponent<RectTransform>().DOAnchorPosX(-100, 0.2f).SetEase(Ease.OutQuad).Play();
|
||||
}else
|
||||
{
|
||||
GetComponent<RectTransform>().DOScale(1f, 0.2f).SetEase(Ease.OutQuad).Play();
|
||||
GetComponent<RectTransform>().GetChild(0).GetComponent<RectTransform>().DOAnchorPosX(0, 0.2f).SetEase(Ease.OutQuad).Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +1,53 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using Ichni.Menu;
|
||||
using Ichni.Menu.UI;
|
||||
using Ichni.UI;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.UI.Extensions;
|
||||
|
||||
namespace Ichni.Menu.UI
|
||||
{
|
||||
public class SongSelectionUIPage : UIPageBase
|
||||
public partial class SongSelectionUIPage : UIPageBase
|
||||
{
|
||||
public SongListControllerUI songListController;
|
||||
|
||||
public bool isLowpassing;
|
||||
public Button lowPassFilterButton;
|
||||
public bool isHighpassing;
|
||||
public Button highPassFilterButton;
|
||||
|
||||
[Title("Test")] public AK.Wwise.Switch defaultSwitch;
|
||||
public Gradient2 backgroundFrames;
|
||||
public float framePositionOffset = -1;
|
||||
|
||||
public SongListControllerUI songListController;
|
||||
public PlaySongUI playSongUI;
|
||||
public SongInfoUI songInfoUI;
|
||||
public DifficultySelectionContainer difficultySelectionContainer;
|
||||
public int currentSelectedDifficultyIndex;
|
||||
|
||||
public AK.Wwise.Switch defaultSwitch;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
MenuAudioManager.instance.audioContainer.SetSwitch(defaultSwitch);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//GenerateSongTabs();
|
||||
MenuAudioManager.instance.audioContainer.SetSwitch(defaultSwitch);
|
||||
currentSelectedDifficultyIndex = 0;
|
||||
|
||||
lowPassFilterButton.onClick.AddListener(() =>
|
||||
{
|
||||
Debug.Log("Low Pass Filter Button Clicked");
|
||||
isLowpassing = !isLowpassing;
|
||||
float value = isLowpassing ? 33f : 100f;
|
||||
MenuAudioManager.instance.audioContainer.SetRTPC("PreviewLowPassFilter", value);
|
||||
});
|
||||
|
||||
highPassFilterButton.onClick.AddListener(() =>
|
||||
{
|
||||
Debug.Log("High Pass Filter Button Clicked");
|
||||
isHighpassing = !isHighpassing;
|
||||
float value = isHighpassing ? 33f : 100f;
|
||||
MenuAudioManager.instance.audioContainer.SetRTPC("PreviewHighPassFilter", value);
|
||||
});
|
||||
Sequence framesSeq = DOTween.Sequence();
|
||||
framesSeq.Append(DOTween.To(() => framePositionOffset, x => framePositionOffset = x, 1f, 1f)
|
||||
.SetEase(Ease.Linear)
|
||||
.OnUpdate(() => backgroundFrames.Offset = framePositionOffset));
|
||||
framesSeq.AppendInterval(4f);
|
||||
framesSeq.SetLoops(-1, LoopType.Restart);
|
||||
framesSeq.Play();
|
||||
}
|
||||
}
|
||||
|
||||
public partial class SongSelectionUIPage
|
||||
{
|
||||
public SongItemData selectedSong;
|
||||
public DifficultyData selectedDifficulty;
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ namespace Ichni.Menu.UI
|
||||
private void Start()
|
||||
{
|
||||
edgeValue = 0;
|
||||
logoFrame.material = Instantiate(logoFrame.material);
|
||||
//logoFrame.material = Instantiate(logoFrame.material);
|
||||
logoFrameExpand = DOTween.To(() => edgeValue, x => edgeValue = x, 1f, 4f)
|
||||
.OnUpdate(() =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user