You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
[System.Serializable]
public class DialogueBehavior : PlayableBehaviour
{
private PlayableDirector playableDirector;
public string characterName;
[TextArea(8,1)]public string dialogueLine;
public int dialogueSize;
bool isClipPlayed; //片段播放结束
public bool requirePause; //玩家需要手动按空格继续
private bool pauseSchedule;
public override void OnPlayableCreate(Playable playable)
{
playableDirector = (playable.GetGraph().GetResolver() as PlayableDirector);
}
//类似MonoBeha的Update每帧都会调用
public override void ProcessFrame(Playable playable, FrameData info, object playerData)
{
if(isClipPlayed == false && info.weight > 0)
{
UIManager.instance.SetupDialogue(characterName, dialogueLine, dialogueSize);
if(requirePause == true)
pauseSchedule = true;
isClipPlayed = true;
}
}
public override void OnBehaviourPause(Playable playable, FrameData info)
{
isClipPlayed = false;
//Debug.Log("片段已暂停!!!!!!!");
if(pauseSchedule)
{
pauseSchedule = false;
//暂停Timeline播放
GameManager.instance.PauseTimeline(playableDirector);
}
else
{
UIManager.instance.ToggleDialogueBox(false);
}
}
}