perf
This commit is contained in:
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user