37 lines
948 B
C#
37 lines
948 B
C#
using Invector;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DG.Tweening;
|
|
|
|
namespace Beyond
|
|
{
|
|
public class vDestroyFadeMaterial : MonoBehaviour
|
|
{
|
|
public float fadeTime = 1f;
|
|
private vDestroyGameObject vDestroyGameObject;
|
|
private Material material;
|
|
|
|
private void Awake()
|
|
{
|
|
vDestroyGameObject = GetComponent<vDestroyGameObject>();
|
|
material = GetComponentInChildren<Renderer>().material;
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
if (material != null && vDestroyGameObject != null)
|
|
{
|
|
material.DOFade(1f, 0f);
|
|
StartCoroutine(FadeDelay(vDestroyGameObject.delay - fadeTime));
|
|
}
|
|
}
|
|
|
|
private IEnumerator FadeDelay(float delay)
|
|
{
|
|
yield return new WaitForSeconds(delay);
|
|
material.DOFade(0f, fadeTime);
|
|
}
|
|
}
|
|
}
|