46 lines
864 B
C#
46 lines
864 B
C#
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
public class Tip: MonoBehaviour
|
|||
|
|
{
|
|||
|
|
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")]
|
|||
|
|
public Transform FollowTran;
|
|||
|
|
|
|||
|
|
[Header("ƫ<><C6AB>ֵ")]
|
|||
|
|
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;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|