For specific reference, a blog https://blog.csdn.net/qq_42461824/article/details/85117312
is actually converting the position of the UI to the position under the screen, so that it can be easily operated. Attach mine below. Unity code `insert here using UnityEngine;
using System.Collections;
public class SpriteController : MonoBehaviour
{ public Transform XuePosition;
public Transform XueTiaoTransform;
// Use this for initialization
void Start()
{
XuePosition = this.transform.Find("XuePosition").transform;
XueTiaoTransform = this.transform.Find("Canvas/XueTiao").transform;
}
// Update is called once per frame
void Update()
{
SetMyHealthBar();
}
private void SetMyHealthBar()
{
Vector3 pos = Camera.main.WorldToScreenPoint(XuePosition.position);
XueTiaoTransform.position = pos;
}
}
code slice`