public override void ProcessFrame(Playable playable, FrameData info, object playerData) { Image imageObject = playerData as Image; if (!imageObject) { return; } Color currentColor = new Color(0, 0, 0, 0); float currentAlpha = 0; int numberOfClips = playable.GetInputCount(); for (int i = 0; i < numberOfClips; i++) { float clipWeight = playable.GetInputWeight(i); if (clipWeight > 0f) { ScriptPlayable <PlayableImageBehaviour> clipPlayable = (ScriptPlayable <PlayableImageBehaviour>)playable.GetInput(i); PlayableImageBehaviour clipBehaviour = clipPlayable.GetBehaviour(); currentColor = clipBehaviour.imageColor; currentAlpha = clipWeight; } } imageObject.color = new Color(currentColor.r, currentColor.g, currentColor.b, currentAlpha); }
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner) { var playable = ScriptPlayable <PlayableImageBehaviour> .Create(graph); PlayableImageBehaviour playableImageBehaviour = playable.GetBehaviour(); playableImageBehaviour.imageColor = imageColor; return(playable); }