using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; public class PlayerLabel : MonoBehaviour { [HideInInspector] public Transform player; public TextMeshProUGUI playerName; public TextMeshProUGUI controller; RectTransform rectTransform; new Camera camera; void Awake() { camera = Camera.main; rectTransform = GetComponent(); playerName = GetComponentInChildren(); } void LateUpdate() { if (!player) return; rectTransform.position = camera.WorldToScreenPoint(player.position + 1.5f * Vector3.up); } public void SetName(string text) => playerName.text = text; public void SetController(string text) => controller.text = text; }