меню паузы, механика записок и лифта
This commit is contained in:
1 parent
cbda26dfc0
commit
cdd1055fd8
55 files changed
+3860
-1087
No files matched your search
@@ -0,0 +1,76 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
/// Плашка подсказки взаимодействия (например "[E] ПРОЧЕСТЬ ЗАПИСКУ"),
|
||||
/// отображаемая по центру экрана под прицелом, когда игрок подходит к интерактивному объекту.
|
||||
/// </summary>
|
||||
public class InteractionPromptUI : MonoBehaviour
|
||||
{
|
||||
private static InteractionPromptUI _instance;
|
||||
public static InteractionPromptUI Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = Object.FindAnyObjectByType<InteractionPromptUI>(FindObjectsInactive.Include);
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] private GameObject promptRoot;
|
||||
[SerializeField] private Text promptText;
|
||||
|
||||
private float hideTimer = 0f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_instance = this;
|
||||
if (promptRoot == null)
|
||||
{
|
||||
promptRoot = transform.childCount > 0 ? transform.GetChild(0).gameObject : gameObject;
|
||||
}
|
||||
HidePromptImmediate();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (hideTimer > 0f)
|
||||
{
|
||||
hideTimer -= Time.unscaledDeltaTime;
|
||||
if (hideTimer <= 0f)
|
||||
{
|
||||
HidePromptImmediate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowPrompt(string message, float duration = 0.25f)
|
||||
{
|
||||
if (promptRoot != null)
|
||||
{
|
||||
if (!promptRoot.activeSelf) promptRoot.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gameObject.activeSelf) gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
if (promptText != null)
|
||||
{
|
||||
promptText.text = message;
|
||||
}
|
||||
hideTimer = duration;
|
||||
}
|
||||
|
||||
public void HidePromptImmediate()
|
||||
{
|
||||
if (promptRoot != null && promptRoot != gameObject)
|
||||
{
|
||||
promptRoot.SetActive(false);
|
||||
}
|
||||
hideTimer = 0f;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user