// Copyright (c) Pixel Crushers. All rights reserved.
using UnityEngine;
namespace PixelCrushers.DialogueSystem
{
///
/// Contains all dialogue (conversation) controls for a Unity UI Dialogue UI.
///
[System.Serializable]
public class UnityUIDialogueControls : AbstractDialogueUIControls
{
///
/// The panel containing the dialogue controls. A panel is optional, but you may want one
/// so you can include a background image, panel-wide effects, etc.
///
[Tooltip("Panel containing the entire conversation UI")]
public UnityEngine.UI.Graphic panel;
[Tooltip("Optional animation transitions; panel should have an Animator")]
public UIAnimationTransitions animationTransitions = new UIAnimationTransitions();
///
/// The NPC subtitle controls.
///
public UnityUISubtitleControls npcSubtitle;
///
/// The PC subtitle controls.
///
public UnityUISubtitleControls pcSubtitle;
///
/// The response menu controls.
///
public UnityUIResponseMenuControls responseMenu;
public override AbstractUISubtitleControls npcSubtitleControls
{
get { return npcSubtitle; }
}
public override AbstractUISubtitleControls pcSubtitleControls
{
get { return pcSubtitle; }
}
public override AbstractUIResponseMenuControls responseMenuControls
{
get { return responseMenu; }
}
private UIShowHideController m_showHideController = null;
private UIShowHideController showHideController
{
get
{
if (m_showHideController == null) m_showHideController = new UIShowHideController(null, panel, animationTransitions.transitionMode, animationTransitions.debug);
return m_showHideController;
}
}
public override void SetActive(bool value) // Must also play animation transitions to set active/inactive.
{
if (value == true)
{
ShowPanel();
}
else
{
HidePanel();
}
}
public override void ShowPanel()
{
ActivateUIElements();
animationTransitions.ClearTriggers(showHideController);
showHideController.Show(animationTransitions.showTrigger, false, null);
}
private void HidePanel()
{
animationTransitions.ClearTriggers(showHideController);
showHideController.Hide(animationTransitions.hideTrigger, DeactivateUIElements);
}
public void ActivateUIElements()
{
Tools.SetGameObjectActive(panel, true);
//base.SetActive(true); // Don't show NPC, PC, Response Menu subpanels in case overrides supercede them.
}
public void DeactivateUIElements()
{
Tools.SetGameObjectActive(panel, false);
base.SetActive(false); // Hides subpanels.
}
}
}