First Commit

This commit is contained in:
bybohka committed 2026-11-19 23:24:44 +03:00
commit eed6b79efc
2836 files changed
+948481

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Подпись над объектом в мире (полка с канистрами, ноутбук, домкрат, мойка, площадка продажи).
/// Показывается GuideSystem, когда игрок рядом: что это и какой клавишей пользоваться.
/// </summary>
public class WorldLabel : MonoBehaviour
{
public static readonly List<WorldLabel> All = new List<WorldLabel>();
[TextArea] public string title = "Объект";
[TextArea] public string hint = "";
public Vector3 offset = new Vector3(0f, 1.2f, 0f);
public float showDistance = 9f;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void ResetStatics() => All.Clear();
private void OnEnable()
{
if (!All.Contains(this)) All.Add(this);
}
private void OnDisable() => All.Remove(this);
public Vector3 WorldPoint => transform.position + offset;
public static WorldLabel Add(GameObject go, string title, string hint, Vector3 offset, float distance = 9f)
{
WorldLabel l = go.GetComponent<WorldLabel>();
if (l == null) l = go.AddComponent<WorldLabel>();
l.title = title;
l.hint = hint;
l.offset = offset;
l.showDistance = distance;
return l;
}
}