Example #1
0
    // NOTE: This function is called at runtime and edit time.  Keep that in mind when setting the values of properties.
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        if (!textMeshProUGUI || !backgroundImage)
        {
            return;
        }

        int inputCount = playable.GetInputCount();

        ToggleSubtitle(false);
        for (int i = 0; i < inputCount; i++)
        {
            float inputWeight = playable.GetInputWeight(i);
            ScriptPlayable <SubtitleTimelineBehaviour> inputPlayable = (ScriptPlayable <SubtitleTimelineBehaviour>)playable.GetInput(i);
            SubtitleTimelineBehaviour input = inputPlayable.GetBehaviour();
            var clip         = clips[i];
            var clipProgress = Mathf.Min((float)(director.time - clip.start), (float)clip.duration) / (float)clip.duration;
            if (clip.start <= director.time && director.time < clip.start + clip.duration)
            {
                ToggleSubtitle(true);
                UpdateSubtitle(clip.displayName, input.textColor, input.backgroundColor);
            }
            // Use the above variables to process each frame of this playable.
        }
    }
    // public override double duration
    // {
    //     get { return DefaultDuration; }
    // }


    public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    {
        var playable = ScriptPlayable <SubtitleTimelineBehaviour> .Create(graph, template);

        SubtitleTimelineBehaviour clone = playable.GetBehaviour();

        return(playable);
    }