using System; using System.Collections.Generic; using UnityEngine; namespace coa4u { /// /// Fades the target by the given alpha value. The tartet shaders should support transparency in order to use this action. /// class ActionFadeBy : ActionInterval { protected float delta; public ActionFadeBy(float tgtDelta, float tgtDuration) : base(tgtDuration) { delta = tgtDelta; } /// /// Returns a copy of the action. /// public override ActionInstant clone() { return new ActionFadeBy(delta, duration); } /// /// Returns the reversed version of the action, if it is possible. /// public override ActionInstant reverse() { return new ActionFadeBy(-delta, duration); } /// /// This method is called every frame update. /// public override void stepInterval(float dt) { float d = dt / duration; Color tgtColor = renderer.material.color; tgtColor[3] += delta * d; renderer.material.color = tgtColor; } } }