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

35 lines
910 B
C#
Raw Normal View History

2026-04-01 12:23:27 -04:00
using System.Collections;
using System.Collections.Generic;
2025-11-25 21:49:03 -05:00
using UnityEngine;
namespace SpriteShadersUltimate.Demo
{
public class Demo_DisplayTitle : MonoBehaviour
{
public Transform target;
2026-04-01 12:23:27 -04:00
RectTransform rectTransform;
RectTransform rectParent;
2025-11-25 21:49:03 -05:00
2026-04-01 12:23:27 -04:00
void Start()
2025-11-25 21:49:03 -05:00
{
rectTransform = GetComponent<RectTransform>();
rectParent = transform.parent.GetComponent<RectTransform>();
}
2026-04-01 12:23:27 -04:00
void LateUpdate()
2025-11-25 21:49:03 -05:00
{
Vector3 screenPosition = RectTransformUtility.WorldToScreenPoint(Camera.main, target.position);
2026-04-01 12:23:27 -04:00
2025-11-25 21:49:03 -05:00
Vector2 rectPosition;
2026-04-01 12:23:27 -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-04-01 12:23:27 -04:00
}