57 lines
1.2 KiB
C#
57 lines
1.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using NodeCanvas.DialogueTrees;
|
|
using UnityEngine;
|
|
using UnityEngine.Playables;
|
|
|
|
namespace BITKit.Timeline
|
|
{
|
|
public class DialogueBehaviour : PlayableBehaviour
|
|
{
|
|
public DialogueActor actor;
|
|
public string subtitle;
|
|
public double duration;
|
|
private Statement Statement;
|
|
public override void OnBehaviourPlay(Playable playable, FrameData info)
|
|
{
|
|
try
|
|
{
|
|
BITAppForUnity.ThrowIfNotPlaying();
|
|
Statement = new Statement
|
|
{
|
|
text = subtitle,
|
|
meta = duration.ToString(CultureInfo.InvariantCulture)
|
|
};
|
|
DialogueTree.RequestSubtitles(new SubtitlesRequestInfo(actor, Statement, EndAction));
|
|
}
|
|
catch (AppIsNotPlayingException)
|
|
{
|
|
Debug.Log($"{actor.name}: {subtitle}");
|
|
}
|
|
}
|
|
private void EndAction()
|
|
{
|
|
}
|
|
public override void OnBehaviourPause(Playable playable, FrameData info)
|
|
{
|
|
}
|
|
|
|
public override void OnPlayableCreate(Playable playable)
|
|
{
|
|
DialogueTree.OnSubtitlesRequest += OnSubtitlesRequest;
|
|
}
|
|
|
|
private void OnSubtitlesRequest(SubtitlesRequestInfo obj)
|
|
{
|
|
}
|
|
|
|
public override void OnPlayableDestroy(Playable playable)
|
|
{
|
|
DialogueTree.OnSubtitlesRequest -= OnSubtitlesRequest;
|
|
}
|
|
}
|
|
}
|
|
|