44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
|
|
using DG.Tweening;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
public class HomeMessageController : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
// Start is called before the first frame update
|
|||
|
|
float startX;
|
|||
|
|
private void Awake()
|
|||
|
|
{
|
|||
|
|
startX = transform.Find("TextContainer/Content").localPosition.x;
|
|||
|
|
}
|
|||
|
|
void Start()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
float timer = 2;
|
|||
|
|
public float? textWidth = null;
|
|||
|
|
[HideInInspector]public bool isAnimated = false;
|
|||
|
|
// Update is called once per frame
|
|||
|
|
void Update()
|
|||
|
|
{
|
|||
|
|
timer -= Time.deltaTime;
|
|||
|
|
if (timer <= 0)
|
|||
|
|
{
|
|||
|
|
//do
|
|||
|
|
if (textWidth.HasValue && textWidth > 180 && !isAnimated)
|
|||
|
|
{
|
|||
|
|
isAnimated = true;
|
|||
|
|
var offset = textWidth.Value - 180;
|
|||
|
|
var game = transform.Find("TextContainer/Content");
|
|||
|
|
game.DOLocalMoveX(startX - offset, 0.5f).onComplete
|
|||
|
|
= () => Invoke("returnAni", 1.5f);
|
|||
|
|
}
|
|||
|
|
timer += 4;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
void returnAni()
|
|||
|
|
{
|
|||
|
|
transform.Find("TextContainer/Content").DOLocalMoveX(startX, 0.5f);
|
|||
|
|
}
|
|||
|
|
}
|