Custom action would be best, something like this:
using RAIN.Action;
using RAIN.Representation;
using UnityEngine;
[RAINAction]
public class SetCanvasVisibility : RAINAction
{
public Expression Target = new Expression();
public Expression Value = new Expression();
public override ActionResult Execute(RAIN.Core.AI ai)
{
if (!Target.IsValid || !Value.IsValid)
return ActionResult.FAILURE;
GameObject tTarget = ai.WorkingMemory.GetItem<GameObject>(Target.VariableName);
if (tTarget == null)
return ActionResult.FAILURE;
Canvas tCanvas = tTarget.GetComponentInChildren<Canvas>();
tCanvas.enabled = Value.Evaluate<bool>(ai.DeltaTime, ai.WorkingMemory);
return ActionResult.SUCCESS;
}
}
If you want something a little less jarring, I would add a Canvas Group to the Canvas, and fade the alpha on that. I’d probably create a small component with FadeIn/FadeOut functions to handle the actual fading on the Canvas Group, and just look for that on the target instead of the Canvas itself.