mirror of
https://github.com/ConjureETS/Bomberman.git
synced 2026-03-24 02:10:59 +00:00
31 lines
731 B
C#
31 lines
731 B
C#
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<RectTransform>();
|
|
|
|
playerName = GetComponentInChildren<TextMeshProUGUI>();
|
|
}
|
|
|
|
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;
|
|
} |