#if HAVE_NODECANVAS using System; using UnityEngine; using ParadoxNotion.Design; using NodeCanvas.Framework; using Framework.Support; namespace Framework.Cinematics { /// Changes the alpha value of a standard shader based material [Category("Material")] [Description("Change the transparency level of a standard shader based material")] public class SetMaterialAlphaTask : ActionTask { /// Game object whose materials will be faded [RequiredField] public BBParameter ObjectToChange; /// Opacity level that will be assigned to the material public float Opacity = 0.5f; /// Summary of what this action does protected override string info { get { return "Set " + this.ObjectToChange.ToString() + " alpha to " + this.Opacity.ToString("0.0"); } } /// Called once when the action is executed protected override void OnExecute() { Material[] materials = MaterialHelper.GetMeshMaterials(this.ObjectToChange.value); int materialCount = materials.Length; for(int index = 0; index < materialCount; ++index) { Color color = materials[index].color; color.a = this.Opacity; materials[index].color = color; } EndAction(); } } } // namespace Framework.Cinematics #endif // HAVE_NODECANVAS