using System.Collections; using System.Collections.Generic; using UnityEngine; public class DissolveEffect : MonoBehaviour { public float Time; List _renderer = new List(); public string Param = "_Dissolve"; public float From = 0; public float To = 1; void Start() { _renderer.AddRange(GetComponentsInChildren()); } [ContextMenu("Dissolve")] public void Dissolve() { LeanTween.value(From, To, 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(Param, x); } } }); } }