Files
Continentis/Assets/OtherPlugins/Sprite Shaders Ultimate/Demo/Scripts/Demo_DisplayTitle.cs

32 lines
884 B
C#
Raw Normal View History

2025-11-25 21:49:03 -05:00
using UnityEngine;
namespace SpriteShadersUltimate.Demo
{
public class Demo_DisplayTitle : MonoBehaviour
{
public Transform target;
2026-03-20 11:56:50 -04:00
private RectTransform rectParent;
2025-11-25 21:49:03 -05:00
2026-03-20 11:56:50 -04:00
private RectTransform rectTransform;
2025-11-25 21:49:03 -05:00
2026-03-20 11:56:50 -04:00
private void Start()
2025-11-25 21:49:03 -05:00
{
rectTransform = GetComponent<RectTransform>();
rectParent = transform.parent.GetComponent<RectTransform>();
}
2026-03-20 11:56:50 -04:00
private void LateUpdate()
2025-11-25 21:49:03 -05:00
{
Vector3 screenPosition = RectTransformUtility.WorldToScreenPoint(Camera.main, target.position);
2026-03-20 11:56:50 -04:00
2025-11-25 21:49:03 -05:00
Vector2 rectPosition;
2026-03-20 11:56:50 -04:00
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectParent, screenPosition, Camera.main,
out rectPosition);
2025-11-25 21:49:03 -05:00
rectTransform.anchoredPosition = rectPosition;
transform.localScale = target.lossyScale;
}
}
2026-03-20 11:56:50 -04:00
}