update
This commit is contained in:
@@ -96,14 +96,7 @@ namespace Ichni.Menu.UI
|
||||
|
||||
if (songItemPrefab != null)
|
||||
{
|
||||
for (int i = 0; i < songTitles.Count; i++)
|
||||
{
|
||||
GameObject itemGO = Instantiate(songItemPrefab, content);
|
||||
itemGO.name = $"Song_{i}_{songTitles[i]}";
|
||||
Text itemText = itemGO.GetComponentInChildren<Text>();
|
||||
if (itemText != null) itemText.text = songTitles[i];
|
||||
songItems.Add(itemGO.GetComponent<RectTransform>());
|
||||
}
|
||||
GenerateSongTabs();
|
||||
}
|
||||
|
||||
Canvas.ForceUpdateCanvases();
|
||||
@@ -115,7 +108,17 @@ namespace Ichni.Menu.UI
|
||||
}
|
||||
}
|
||||
|
||||
Tweener contentTween;
|
||||
public void GenerateSongTabs()
|
||||
{
|
||||
string chapter = ChapterSelectionManager.instance.currentChapter;
|
||||
ChapterSelectionUnit chapterUnit = ChapterSelectionManager.instance.chapters.Find(c => c.chapterIndex == chapter);
|
||||
foreach (SongItemData song in chapterUnit.songs)
|
||||
{
|
||||
SongSelectionTabUI tab = Instantiate(songItemPrefab ,content).GetComponent<SongSelectionTabUI>();
|
||||
songItems.Add(tab.GetComponent<RectTransform>());
|
||||
tab.SetUpTab(song);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
@@ -190,6 +193,22 @@ namespace Ichni.Menu.UI
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator SnapToTab(SongSelectionTabUI 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));
|
||||
}
|
||||
|
||||
private IEnumerator SnapToItem(RectTransform targetItem, bool immediate)
|
||||
{
|
||||
if (!immediate)
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Ichni.Menu.UI
|
||||
public TMP_Text songNameText;
|
||||
public Button switchDifficultyButton;
|
||||
public Button previewButton;
|
||||
public Button startSongButton;
|
||||
public string currentDifficultyName;
|
||||
|
||||
[Title("背景图&选中处理")]
|
||||
@@ -45,6 +46,19 @@ namespace Ichni.Menu.UI
|
||||
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));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using Ichni.Menu;
|
||||
using Ichni.Menu.UI;
|
||||
using Ichni.UI;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -11,18 +12,19 @@ namespace Ichni.Menu.UI
|
||||
{
|
||||
public class SongSelectionUIPage : UIPageBase
|
||||
{
|
||||
public GameObject songSelectionTabPrefab;
|
||||
public RectTransform songSelectionTabContainer;
|
||||
public List<SongSelectionTabUI> songSelectionTabs;
|
||||
public SongListControllerUI songListController;
|
||||
|
||||
public bool isLowpassing;
|
||||
public Button lowPassFilterButton;
|
||||
public bool isHighpassing;
|
||||
public Button highPassFilterButton;
|
||||
|
||||
[Title("Test")] public AK.Wwise.Switch defaultSwitch;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//GenerateSongTabs();
|
||||
MenuAudioManager.instance.audioContainer.SetSwitch(defaultSwitch);
|
||||
|
||||
lowPassFilterButton.onClick.AddListener(() =>
|
||||
{
|
||||
@@ -40,25 +42,5 @@ namespace Ichni.Menu.UI
|
||||
MenuAudioManager.instance.audioContainer.SetRTPC("PreviewHighPassFilter", value);
|
||||
});
|
||||
}
|
||||
|
||||
public void GenerateSongTabs()
|
||||
{
|
||||
string chapter = ChapterSelectionManager.instance.currentChapter;
|
||||
ChapterSelectionUnit chapterUnit = ChapterSelectionManager.instance.chapters.Find(c => c.chapterIndex == chapter);
|
||||
foreach (SongItemData song in chapterUnit.songs)
|
||||
{
|
||||
SongSelectionTabUI tab = Instantiate(songSelectionTabPrefab, songSelectionTabContainer).GetComponent<SongSelectionTabUI>();
|
||||
tab.SetUpTab(song);
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearTabs()
|
||||
{
|
||||
foreach (SongSelectionTabUI tab in songSelectionTabs)
|
||||
{
|
||||
Destroy(tab.gameObject);
|
||||
}
|
||||
songSelectionTabs.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user