AK056/Assets/GameLogic/Game/Extension/GameObjectExtension.cs
2025-05-09 15:40:34 +08:00

39 lines
1.3 KiB
C#

using PrimeTween;
using UnityEngine;
namespace GameLogic
{
public static class GameObjectExtension
{
public static void SetPosition(this GameObject self, Vector3 position)
{
self.transform.position = position;
}
public static void SetPosition(this GameObject self, Transform transform)
{
self.transform.position = transform.position;
}
public static void SetTransformNoScale(this GameObject self, Transform transform)
{
self.transform.position = transform.position;
self.transform.rotation = transform.rotation;
}
public static void SetTransform(this GameObject self, Transform transform)
{
self.transform.position = transform.position;
self.transform.rotation = transform.rotation;
self.transform.localScale = transform.localScale;
}
public static void SetParent(this GameObject self, Transform parent)
{
self.transform.SetParent(parent);
}
public static void SetParentLocalPositionZero(this GameObject self, Transform parent)
{
self.transform.SetParent(parent);
Tween.LocalPosition(self.transform, Vector3.zero, 0.5f);
}
}
}