// Copyright (c) Pixel Crushers. All rights reserved.
using UnityEngine;
using System;
namespace PixelCrushers.DialogueSystem
{
///
/// Implements IBarkUI using Unity UI.
///
[AddComponentMenu("")] // Use wrapper.
public class UnityUIBarkUI : AbstractBarkUI
{
///
/// The (optional) UI canvas group. If assigned, the fade will occur on this
/// control. The other controls should be children of this canvas group.
///
[Tooltip("Optional canvas group, for example to play fade animations.")]
public CanvasGroup canvasGroup = null;
///
/// The UI text control for the bark text.
///
[Tooltip("UI text control for the bark text.")]
public UnityEngine.UI.Text barkText = null;
///
/// The (optional) UI text control for the actor's name, if includeName is true.
/// If null, the name is added to the front of the subtitle text instead.
///
[Tooltip("Optional UI text control for the actor's name if Include Name is ticked. If unassigned and Include Name is ticked, the name is prepended to the Bark Text.")]
public UnityEngine.UI.Text nameText = null;
///
/// Set true to include the barker's name in the text.
///
[Tooltip("Show the barker's name.")]
public bool includeName = false;
[HideInInspector]
public float doneTime = 0;
[Serializable]
public class AnimationTransitions
{
public string showTrigger = "Show";
public string hideTrigger = "Hide";
}
public AnimationTransitions animationTransitions = new AnimationTransitions();
///
/// The duration in seconds to show the bark text before fading it out.
///
[Tooltip("The duration in seconds to show the bark text before fading it out. If zero, use the Dialogue Manager's Bark Settings.")]
public float duration = 4f;
///
/// Set true to keep the bark text onscreen until the sequence ends.
///
[Tooltip("Keep the bark text onscreen until the sequence ends.")]
public bool waitUntilSequenceEnds = false;
///
/// Wait for an "OnContinue" message.
///
public bool waitForContinueButton = false;
///
/// The text display setting. Defaults to use the same subtitle setting as the Dialogue
/// Manager, but you can also set it to always show or always hide the text.
///
public BarkSubtitleSetting textDisplaySetting = BarkSubtitleSetting.SameAsDialogueManager;
private Canvas canvas = null;
private Animator animator = null;
///
/// Indicates whether a bark is currently playing.
///
///
/// true if playing; otherwise, false.
///
public override bool isPlaying
{
get
{
return (canvas != null) && canvas.enabled && (DialogueTime.time < doneTime);
}
}
public void Awake()
{
canvas = GetComponentInChildren