//比如置灰,等方便的功能,用此脚本
public class UIMaterialEffect : MonoBehaviour
{
[SerializeField] private Material mat;
[SerializeField] private Graphic graphic;
#if UNITY_EDITOR
[ContextMenu("Enable")]
private void EnableEffect()
{
SetEffectActive(true);
}
[ContextMenu("Disable")]
private void DisableEffect()
{
SetEffectActive(false);
}
#endif
public void SetEffectActive(bool active)
{
if (graphic != null)
{
graphic.material = active ? mat : null;
}
}
}