Initial commit

This commit is contained in:
2026-02-10 21:27:46 +00:00
commit 3a8163af21
3261 changed files with 563042 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
using UnityEngine;
using TMPro;
using UnityEngine.UI;
public class NameplateController : MonoBehaviour
{
[Header("UI refs")]
public TextMeshProUGUI nameText;
public Image backgroundImage; // optional background to tint
public Outline uiOutline; // optional UI outline component (for name text)
Camera mainCam;
Transform target;
void Awake()
{
mainCam = Camera.main;
}
public void Initialize(Selectable s, Color color, Vector3 offset)
{
target = s.transform;
if (nameText != null) nameText.text = s.displayName;
ApplyColor(color);
FollowTarget(target, offset);
}
public void FollowTarget(Transform t, Vector3 offset)
{
if (t == null) return;
Vector3 worldPos = t.position + offset;
transform.position = worldPos;
// Face camera
if (mainCam != null)
{
transform.rotation = Quaternion.LookRotation(transform.position - mainCam.transform.position);
}
}
void ApplyColor(Color c)
{
if (nameText != null) nameText.color = c;
if (backgroundImage != null) backgroundImage.color = new Color(c.r, c.g, c.b, backgroundImage.color.a);
if (uiOutline != null) uiOutline.effectColor = c;
}
}