rabidus-test/Assets/DissolveEffect.cs

31 lines
720 B
C#
Raw Normal View History

2023-10-17 14:17:56 +03:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DissolveEffect : MonoBehaviour
{
public float Time;
List<Renderer> _renderer = new List<Renderer>();
void Start()
{
_renderer.AddRange(GetComponentsInChildren<Renderer>());
}
[ContextMenu("Dissolve")]
public void Dissolve()
{
LeanTween.value(0, 1, Time).setOnUpdate((float x) =>
{
for (int i = 0; i < _renderer.Count; i++)
{
for (int h = 0; h < _renderer[i].materials.Length; h++)
{
_renderer[i].materials[h].SetFloat("_Dissolve", x);
}
}
});
}
}