59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
using System;
|
|
using PixelCrushers.DialogueSystem;
|
|
using UnityEngine;
|
|
using PixelCrushers.DialogueSystem.Wrappers;
|
|
|
|
namespace Beyond
|
|
{
|
|
[RequireComponent(typeof(CanvasGroup))]
|
|
public class HideUI : MonoBehaviour
|
|
{
|
|
public static Action<bool> SetActive;
|
|
|
|
private CanvasGroup m_canvasGroup;
|
|
private bool interactable;
|
|
private bool blocksRaycasts;
|
|
|
|
public static void InvokeSetActiveUI(bool isActive)
|
|
{
|
|
SetActive?.Invoke(isActive);
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
m_canvasGroup = GetComponent<CanvasGroup>();
|
|
interactable = m_canvasGroup.interactable;
|
|
blocksRaycasts = m_canvasGroup.blocksRaycasts;
|
|
SetActive += OnSetActive;
|
|
}
|
|
|
|
private void OnConversationStarted(Transform t)
|
|
{
|
|
OnSetActive(false);
|
|
}
|
|
private void OnConversationEnded(Transform t)
|
|
{
|
|
OnSetActive(true);
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
DialogueManager.instance.conversationStarted += OnConversationStarted;
|
|
DialogueManager.instance.conversationEnded += OnConversationEnded;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
SetActive -= OnSetActive;
|
|
if (DialogueManager.instance != null)
|
|
DialogueManager.instance.conversationStarted -= OnConversationStarted;
|
|
if (DialogueManager.instance != null)
|
|
DialogueManager.instance.conversationEnded -= OnConversationEnded;
|
|
}
|
|
|
|
private void OnSetActive(bool isActive)
|
|
{
|
|
m_canvasGroup.gameObject.SetActive(isActive);
|
|
}
|
|
}
|
|
} |