2025-07-08 22:07:35 +08:00
|
|
|
|
using System;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace HK
|
|
|
|
|
{
|
|
|
|
|
public class UpdateTransform : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
private Transform target;
|
2025-08-22 09:16:11 +08:00
|
|
|
|
bool isRuning = false;
|
2025-07-08 22:07:35 +08:00
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetData(Transform target)
|
|
|
|
|
{
|
|
|
|
|
this.target = target;
|
2025-08-22 09:16:11 +08:00
|
|
|
|
isRuning = true;
|
2025-07-08 22:07:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
{
|
2025-08-22 09:16:11 +08:00
|
|
|
|
if (!isRuning) return;
|
|
|
|
|
if (target == null)
|
|
|
|
|
GameObject.Destroy(this.gameObject);
|
|
|
|
|
if (transform == null || target == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2025-07-08 22:07:35 +08:00
|
|
|
|
transform.localPosition = target.localPosition;
|
|
|
|
|
transform.localScale = target.localScale;
|
|
|
|
|
transform.localRotation = target.localRotation;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|