161 lines
4.7 KiB
C#
161 lines
4.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
using DG.Tweening;
|
|
using DG.Tweening.Core;
|
|
|
|
public class ClockScrolling : MonoBehaviour
|
|
{
|
|
public List<TextMeshProUGUI> text_mesh_pros = new List<TextMeshProUGUI>();
|
|
|
|
int Current = 0;
|
|
int Last => Current == 0 ? text_mesh_pros.Count - 1 : Current - 1;
|
|
int Next => Current == text_mesh_pros.Count - 1 ? 0 : Current + 1;
|
|
|
|
float timer;
|
|
bool hide_scrolling;
|
|
|
|
void Update()
|
|
{
|
|
#if UNITY_EDITOR
|
|
if (Input.GetKeyDown(KeyCode.LeftArrow))
|
|
{
|
|
ScrollingUp();
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.RightArrow))
|
|
{
|
|
ScrollingDown();
|
|
}
|
|
#endif
|
|
timer += Time.deltaTime;
|
|
if (timer >= 3)
|
|
{
|
|
if (!hide_scrolling)
|
|
{
|
|
hide_scrolling = true;
|
|
next_color_tween = text_mesh_pros[Next].DOColor(new Color(1, 1, 1, 0f), 1f);
|
|
last_color_tween = text_mesh_pros[Last].DOColor(new Color(1, 1, 1, 0f), 1f);
|
|
}
|
|
}
|
|
|
|
}
|
|
TweenerCore<Color, Color, DG.Tweening.Plugins.Options.ColorOptions> next_color_tween;
|
|
TweenerCore<Color, Color, DG.Tweening.Plugins.Options.ColorOptions> last_color_tween;
|
|
|
|
public void ScrollingUp()
|
|
{
|
|
//ÖÕÖ¹
|
|
if (hide_scrolling)
|
|
{
|
|
if (next_color_tween.IsPlaying())
|
|
{
|
|
next_color_tween.Kill();
|
|
}
|
|
if (last_color_tween.IsPlaying())
|
|
{
|
|
last_color_tween.Kill();
|
|
}
|
|
}
|
|
|
|
Current = Next;
|
|
|
|
text_mesh_pros[Current].rectTransform.DOAnchorPos(Vector2.zero, 0.25f);
|
|
DOTween.To(() => text_mesh_pros[Current].fontSize, (_v) => text_mesh_pros[Current].fontSize = _v, 26, 0.25f);
|
|
text_mesh_pros[Current].DOColor(Color.white, 0.25f);
|
|
|
|
text_mesh_pros[Next].rectTransform.DOAnchorPos(new Vector2(0, -25), 0.25f);
|
|
DOTween.To(() => text_mesh_pros[Next].fontSize, (_v) => text_mesh_pros[Next].fontSize = _v, 21, 0.25f);
|
|
text_mesh_pros[Next].DOColor(new Color(1, 1, 1, 0.5f), 0.25f);
|
|
|
|
text_mesh_pros[Last].rectTransform.DOAnchorPos(new Vector2(0, 25), 0.25f);
|
|
DOTween.To(() => text_mesh_pros[Last].fontSize, (_v) => text_mesh_pros[Last].fontSize = _v, 21, 0.25f);
|
|
text_mesh_pros[Last].DOColor(new Color(1, 1, 1, 0.5f), 0.25f);
|
|
|
|
timer = 0;
|
|
hide_scrolling = false;
|
|
}
|
|
|
|
public void ScrollingDown()
|
|
{
|
|
//ÖÕÖ¹
|
|
if (hide_scrolling)
|
|
{
|
|
if (next_color_tween.IsPlaying())
|
|
{
|
|
next_color_tween.Kill();
|
|
}
|
|
if (last_color_tween.IsPlaying())
|
|
{
|
|
last_color_tween.Kill();
|
|
}
|
|
}
|
|
|
|
Current = Last;
|
|
|
|
text_mesh_pros[Current].rectTransform.DOAnchorPos(Vector2.zero, 0.25f);
|
|
DOTween.To(() => text_mesh_pros[Current].fontSize, (_v) => text_mesh_pros[Current].fontSize = _v, 26, 0.25f);
|
|
text_mesh_pros[Current].DOColor(Color.white, 0.25f);
|
|
|
|
text_mesh_pros[Next].rectTransform.DOAnchorPos(new Vector2(0, -25), 0.25f);
|
|
DOTween.To(() => text_mesh_pros[Next].fontSize, (_v) => text_mesh_pros[Next].fontSize = _v, 21, 0.25f);
|
|
text_mesh_pros[Next].DOColor(new Color(1, 1, 1, 0.5f), 0.25f);
|
|
|
|
text_mesh_pros[Last].rectTransform.DOAnchorPos(new Vector2(0, 25), 0.25f);
|
|
DOTween.To(() => text_mesh_pros[Last].fontSize, (_v) => text_mesh_pros[Last].fontSize = _v, 21, 0.25f);
|
|
text_mesh_pros[Last].DOColor(new Color(1, 1, 1, 0.5f), 0.25f);
|
|
|
|
timer = 0;
|
|
hide_scrolling = false;
|
|
}
|
|
|
|
public void SetNextText(string _text)
|
|
{
|
|
//if (_text == "ÉîÛÚÊÐÃñÖÐÐÄ")
|
|
//{
|
|
// text_mesh_pros[Next].text = "¹ã³¡1";
|
|
//}
|
|
//else if (_text == "Î÷ÀöºþÐ£Çø")
|
|
//{
|
|
// text_mesh_pros[Next].text = "¹ã³¡2";
|
|
//}
|
|
//else
|
|
{
|
|
text_mesh_pros[Next].text = _text;
|
|
}
|
|
}
|
|
|
|
public string SetCurrentText(string _text)
|
|
{
|
|
//if (_text == "ÉîÛÚÊÐÃñÖÐÐÄ")
|
|
//{
|
|
// text_mesh_pros[Current].text = "¹ã³¡1";
|
|
//}
|
|
//else if (_text == "Î÷ÀöºþÐ£Çø")
|
|
//{
|
|
// text_mesh_pros[Current].text = "¹ã³¡2";
|
|
//}
|
|
//else
|
|
{
|
|
text_mesh_pros[Current].text = _text;
|
|
}
|
|
return _text;
|
|
}
|
|
public void SetLastText(string _text)
|
|
{
|
|
//if (_text == "ÉîÛÚÊÐÃñÖÐÐÄ")
|
|
//{
|
|
// text_mesh_pros[Last].text = "¹ã³¡1";
|
|
//}
|
|
//else if (_text == "Î÷ÀöºþÐ£Çø")
|
|
//{
|
|
// text_mesh_pros[Last].text = "¹ã³¡2";
|
|
//}
|
|
//else
|
|
{
|
|
text_mesh_pros[Last].text = _text;
|
|
}
|
|
}
|
|
}
|