46 lines
864 B
C#
46 lines
864 B
C#
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<RectTransform>();
|
|
ParentTran = transform.GetComponentInParent<Canvas>().GetComponent<RectTransform>();
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|