2025-05-18 01:04:31 +08:00

83 lines
1.9 KiB
C#

// ***********************************************************************
// Assembly : Game
// Author : Kimch
// Created : 2020-09-02
// Description :
// Last Modified By :
// Last Modified On :
// ***********************************************************************
// <copyright file= "Txt_effect" company="Kimch"></copyright>
// <summary></summary>
// ***********************************************************************
using UnityEngine;
namespace G
{
public class Txt_effect : MonoBehaviour
{
private Material _material;
private Vector3 _startScale;
private Vector3 _targetScale = new Vector3(4f, 1f, 0f);
private float _finishDelay;
private bool _isDelay;
private void Awake()
{
#if UNITY_EDITOR
_material = this.GetComponent<Renderer>().material;
#else
_material = this.GetComponent<Renderer>().sharedMaterial;
#endif
_startScale = transform.localScale;
}
public void TxtEfOn(int index)
{
this.gameObject.SetActive(true);
this.transform.localScale = _startScale;
_finishDelay = 0f;
if (index == 2)
{
this.transform.localScale = Vector3.zero;
_isDelay = true;
}
//if (index == 2 || index == 1)
//{
// transform.GetChild(1).gameObject.SetActive(true);
//}
//else if (index == 3)
//{
// transform.GetChild(0).gameObject.SetActive(true);
//}
if (_material)
_material.mainTextureOffset = Vector2.up * 0.25f * index;
}
private void Update()
{
_finishDelay += Time.deltaTime;
if (_finishDelay > 0.6f)
{
//transform.GetChild(0).gameObject.SetActive(false);
//transform.GetChild(1).gameObject.SetActive(false);
this.gameObject.SetActive(false);
}
else if (_isDelay)
{
if (_finishDelay > 0.2f)
{
this.transform.localScale = _startScale;
_isDelay = false;
}
}
else
{
this.transform.localScale = Vector3.Lerp(transform.localScale, _targetScale, Time.deltaTime * 15f * 5f);
}
}
}
}