using System.Collections; using System.Collections.Generic; using UnityEngine; public class Tip: MonoBehaviour { [Header("¸úËæµÄÎïÌå")] public Transform FollowTran; [Header("Æ«ÒÆÖµ")] public Vector2 Offset; public Camera _camera; RectTransform ParentTran, Rtran; void Start() { Rtran = transform.GetComponent(); ParentTran = transform.GetComponentInParent().GetComponent(); } private void Update() { if (FollowTran != null) { Vector2 mScreenPos = _camera.WorldToScreenPoint(FollowTran.transform.position); Vector2 mRectPos; RectTransformUtility.ScreenPointToLocalPointInRectangle(ParentTran, mScreenPos, null, out mRectPos); Rtran.localPosition = mRectPos + Offset; } } }