Danro/Assets/Scripts/Behaviour/MessagePlaceholder.cs

24 lines
622 B
C#

using UnityEngine;
namespace RR.Common.Behaviour
{
public class MessagePlaceholder : MonoBehaviour
{
private void Update()
{
transform.rotation = Quaternion.identity;
if (transform.parent.localScale != Vector3.one)
{
transform.localScale = Vector3.one / transform.parent.localScale.x;
}
// Используем childCount вместо GetComponentsInChildren — намного быстрее
if (transform.childCount == 0)
{
Destroy(gameObject);
}
}
}
}