Files
Continentis/Assets/OtherPlugins/Sprite Shaders Ultimate/Demo/Scripts/Demo_DisplayTitle.cs
SoulliesOfficial ad4948207e 推进度!
2025-11-25 21:49:03 -05:00

35 lines
910 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace SpriteShadersUltimate.Demo
{
public class Demo_DisplayTitle : MonoBehaviour
{
public Transform target;
RectTransform rectTransform;
RectTransform rectParent;
void Start()
{
rectTransform = GetComponent<RectTransform>();
rectParent = transform.parent.GetComponent<RectTransform>();
}
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;
}
}
}