63 lines
2.1 KiB
C#
63 lines
2.1 KiB
C#
/*
|
|
* FancyScrollView (https://github.com/setchi/FancyScrollView)
|
|
* Copyright (c) 2020 setchi
|
|
* Licensed under MIT (https://github.com/setchi/FancyScrollView/blob/master/LICENSE)
|
|
*/
|
|
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using DG.Tweening;
|
|
using FancyScrollView.Example01;
|
|
using TMPro;
|
|
using Unity.Mathematics;
|
|
using UnityEngine;
|
|
class UI_Panel_Level : MonoBehaviour
|
|
{
|
|
[SerializeField] float anim_Time = 0.5f;
|
|
float Anim_Speed => 1f / anim_Time;
|
|
[SerializeField] List<Animator> ui_Anim;
|
|
[SerializeField] ScrollView scrollView = default;
|
|
[SerializeField] TMP_Text Text_Level;
|
|
private void OnEnable()
|
|
{
|
|
Text_Level.text = "1";
|
|
string text = Text_Level.text;
|
|
//var s = DOTween.Sequence();
|
|
// s.Append(DOTween.To(value => { Text_Level.text = Mathf.Floor(value).ToString(); }, startValue: UnityEngine.Random.Range(0, 99), UnityEngine.Random.Range(0, 99), duration: anim_Time / 4)
|
|
// );
|
|
// s.Append(DOTween.To(value => { Text_Level.text = Mathf.Floor(value).ToString(); }, startValue: UnityEngine.Random.Range(0, 99), UnityEngine.Random.Range(0, 99), duration: anim_Time / 4)
|
|
// );
|
|
// s.Append(DOTween.To(value => { Text_Level.text = Mathf.Floor(value).ToString(); }, startValue: UnityEngine.Random.Range(0, 99), UnityEngine.Random.Range(0, 99), duration: anim_Time / 4)
|
|
// );
|
|
// s.Append(DOTween.To(() => string.Empty, value => Text_Level.text = value, text, anim_Time / 4)
|
|
//);
|
|
|
|
//t.SetOptions(true);
|
|
}
|
|
private void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Escape))
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
void Start()
|
|
{
|
|
foreach (var item in ui_Anim)
|
|
{
|
|
item.speed = Anim_Speed;
|
|
}
|
|
var items = Enumerable.Range(1, 100)
|
|
.Select(i => new ItemData($"{i}"))
|
|
.ToArray();
|
|
|
|
scrollView.UpdateData(items);
|
|
scrollView.Scroller.OnSelectionChanged(Set_Level);
|
|
}
|
|
|
|
private void Set_Level(int obj)
|
|
{
|
|
//obj++;
|
|
//Text_Level.text = obj.ToString();
|
|
}
|
|
} |