32 lines
884 B
C#
32 lines
884 B
C#
using UnityEngine;
|
|
|
|
namespace SpriteShadersUltimate.Demo
|
|
{
|
|
public class Demo_DisplayTitle : MonoBehaviour
|
|
{
|
|
public Transform target;
|
|
private RectTransform rectParent;
|
|
|
|
private RectTransform rectTransform;
|
|
|
|
private void Start()
|
|
{
|
|
rectTransform = GetComponent<RectTransform>();
|
|
rectParent = transform.parent.GetComponent<RectTransform>();
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
Vector3 screenPosition = RectTransformUtility.WorldToScreenPoint(Camera.main, target.position);
|
|
|
|
|
|
Vector2 rectPosition;
|
|
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectParent, screenPosition, Camera.main,
|
|
out rectPosition);
|
|
|
|
rectTransform.anchoredPosition = rectPosition;
|
|
|
|
transform.localScale = target.lossyScale;
|
|
}
|
|
}
|
|
} |