30 lines
805 B
C#
30 lines
805 B
C#
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<Camera>();
|
|
cam = Camera.main;
|
|
rectTransform = this.GetComponent<RectTransform>();
|
|
text = this.GetComponent<Text>();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
pos = cam.WorldToScreenPoint(followtarget.transform.position);
|
|
rectTransform.position = pos+offsetPos;
|
|
}
|
|
}
|