Files
beyond/Assets/Scripts/Dialogue/BeyondBarkUI.cs
2025-02-10 18:03:54 +01:00

105 lines
2.8 KiB
C#

using PixelCrushers.DialogueSystem;
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using static System.Net.Mime.MediaTypeNames;
namespace Beyond
{
public class BeyondBarkUI : StandardBarkUI
{
public CanvasGroup m_statsGroup;
protected override void Start()
{
base.Start();
/*
HideUI.SetActive += (bool b) =>
{
if (!b) InstantHide();
};
*/
}
public virtual void InstantHide()
{
if (canvasGroup)
canvasGroup.gameObject.SetActive(false);
numSequencesActive = 0;
if (CanTriggerAnimations() && !string.IsNullOrEmpty(animationTransitions.hideTrigger))
{
if (!string.IsNullOrEmpty(animationTransitions.hideTrigger))
{
animator.ResetTrigger(animationTransitions.hideTrigger);
}
}
else if (canvas != null)
{
canvas.enabled = false;
}
if (canvas != null) canvas.GetComponent<RectTransform>().localPosition = originalCanvasLocalPosition;
doneTime = 0;
if (m_statsGroup)
m_statsGroup.alpha = 1f;
}
}
/*
public class BeyondBarkUI : AbstractBarkUI
{
public Animator m_animator;
public TextMeshProUGUI m_textToBark;
[HideInInspector]
public float doneTime = 0;
/// <summary>
/// The duration in seconds to show the bark text before fading it out.
/// </summary>
[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;
/// <summary>
/// Indicates whether a bark is currently playing.
/// </summary>
/// <value>
/// <c>true</c> if playing; otherwise, <c>false</c>.
/// </value>
public override bool isPlaying
{
get
{
return (DialogueTime.time < doneTime);
}
}
protected virtual void Awake()
{
m_animator = GetComponent<Animator>();
}
protected void OnEnable()
{
}
public override void Bark(Subtitle subtitle)
{
m_textToBark.text = subtitle.formattedText.text;
m_animator.SetBool("show", true);
CancelInvoke("Hide");
Invoke("Hide", duration);
doneTime = DialogueTime.time + duration;
}
public override void Hide()
{
m_animator.SetBool("show", false);
doneTime = 0;
}
}
*/
}