using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
public Transform target;
public RectTransform canvas;
public RectTransform gauge;
public Camera cam;
void Update()
{
Vector3 offsetPos = target.transform.position;
Vector2 screenPoint = Camera.main.WorldToScreenPoint(offsetPos);
Debug.Log(screenPoint);
Vector2 canvasPos;
RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas, screenPoint, cam, out canvasPos);
gauge.localPosition = canvasPos;
Debug.Log(canvasPos);
}
}