using UnityEngine; using UnityEngine.UI; public class TestMoveToTarget : MonoBehaviour { public RectTransform sourceRect; public RectTransform targetRect; public Vector2 offset = Vector2.zero; public float duration = 1f; [ContextMenu("Test MoveToTarget")] public void TestMove() { if (sourceRect == null || targetRect == null) { BattleDebug.LogError("请在Inspector中指定sourceRect和targetRect!"); return; } BattleUtility.MoveToTarget(sourceRect, targetRect, offset, duration, () => { Debug.Log("移动完成!"); }); } }