Menu基本完成
This commit is contained in:
35
Assets/Scripts/UI/SongSelection/SongSelectionTabUI.cs
Normal file
35
Assets/Scripts/UI/SongSelection/SongSelectionTabUI.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Menu.UI
|
||||
{
|
||||
public class SongSelectionTabUI : MonoBehaviour
|
||||
{
|
||||
public SongItemData connectedSong;
|
||||
public TMP_Text songNameText;
|
||||
public Button switchDifficultyButton;
|
||||
public string currentDifficultyName;
|
||||
|
||||
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;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/SongSelection/SongSelectionTabUI.cs.meta
Normal file
11
Assets/Scripts/UI/SongSelection/SongSelectionTabUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e65fe538f854fc041a6bc0065c5959b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +1,42 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.Menu;
|
||||
using Ichni.Menu.UI;
|
||||
using Ichni.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.UI
|
||||
{
|
||||
public class SongSelectionUIPage : UIPageBase
|
||||
{
|
||||
public GameObject songSelectionTabPrefab;
|
||||
public RectTransform songSelectionTabContainer;
|
||||
public List<SongSelectionTabUI> songSelectionTabs;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GenerateSongTabs();
|
||||
}
|
||||
|
||||
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