Files
MuHua-Core/Packages/LabelFollow/Runtime/LabelFollower.cs
T
2025-02-27 17:40:31 +08:00

21 lines
415 B
C#

using UnityEngine;
namespace MuHua
{
public class LabelFollower : MonoBehaviour
{
public Transform target; // 要跟随的目标物体
public Vector3 offset; // 标签的偏移量
void Update()
{
if (target != null)
{
// 设置标签的位置
transform.position = target.position + offset;
// 使标签面向相机
transform.rotation = Camera.main.transform.rotation;
}
}
}
}