public class ActionGraphicColor : IAction
public GameObjectProperty graphic = new GameObjectProperty();
public float duration = 0.0f;
public ColorProperty color = new ColorProperty(Color.white);
// EXECUTABLE: ----------------------------------------------------------------------------
public override bool InstantExecute(GameObject target, IAction[] actions, int index)
if (this.duration <= 0.0f)
if (this.graphic != null) this.graphic.GetValue(target).GetComponent<Graphic>().color = this.color.GetValue(target);
public override IEnumerator Execute(GameObject target, IAction[] actions, int index)
if (this.graphic != null)
Color currentColor = this.graphic.GetValue(target).GetComponent<Graphic>().color;
Color targetColor = this.color.GetValue(target);
float startTime = Time.unscaledTime;
WaitUntil waitUntil = new WaitUntil(() =>
float t = (Time.unscaledTime - startTime) / this.duration;
this.graphic.GetValue(target).GetComponent<Graphic>().color = Color.Lerp(currentColor, targetColor, t);
this.graphic.GetValue(target).GetComponent<Graphic>().color = targetColor;
// More code to come, but inspector related, not important for this example.