using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using YHElectric; public class UIFollow3DObj : MonoBehaviour { public Transform followtarget; private RectTransform rectTransform; private Text text; public Vector2 offsetPos; Vector2 pos; Camera cam; // Start is called before the first frame update void Start() { //cam = GameManager.instance.cameraRender.GetComponent(); cam = Camera.main; rectTransform = this.GetComponent(); text = this.GetComponent(); } // Update is called once per frame void Update() { pos = cam.WorldToScreenPoint(followtarget.transform.position); rectTransform.position = pos+offsetPos; } }