rabidus-test/Assets/DissolveEffect.cs

37 lines
841 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>();
2023-10-18 17:11:47 +03:00
public string Param = "_Dissolve";
public float From = 0;
public float To = 1;
2023-10-17 14:17:56 +03:00
void Start()
{
_renderer.AddRange(GetComponentsInChildren<Renderer>());
}
2023-10-19 13:42:54 +03:00
private bool _action = false;
2023-10-17 14:17:56 +03:00
[ContextMenu("Dissolve")]
public void Dissolve()
{
2023-10-18 17:11:47 +03:00
LeanTween.value(From, To, Time).setOnUpdate((float x) =>
2023-10-17 14:17:56 +03:00
{
for (int i = 0; i < _renderer.Count; i++)
{
for (int h = 0; h < _renderer[i].materials.Length; h++)
{
2023-10-18 17:11:47 +03:00
_renderer[i].materials[h].SetFloat(Param, x);
2023-10-17 14:17:56 +03:00
}
}
});
}
}