using System.Collections.Generic; using UnityEngine; /// /// Подпись над объектом в мире (полка с канистрами, ноутбук, домкрат, мойка, площадка продажи). /// Показывается GuideSystem, когда игрок рядом: что это и какой клавишей пользоваться. /// public class WorldLabel : MonoBehaviour { public static readonly List All = new List(); [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(); if (l == null) l = go.AddComponent(); l.title = title; l.hint = hint; l.offset = offset; l.showDistance = distance; return l; } }