namespace Zinnia.Extension
{
using UnityEngine;
///
/// Extended methods for the Type.
///
public static class TransformExtensions
{
///
/// The SetGlobalScale method is used to set a scale based on a global scale instead of a local scale.
///
/// The reference to the to scale.
/// The global scale to apply to the given .
public static void SetGlobalScale(this Transform transform, Vector3 globalScale)
{
if (transform == null)
{
return;
}
transform.localScale = Vector3.one;
transform.localScale = globalScale.Divide(transform.lossyScale);
}
///
/// Gets the signed Euler angle of the .
///
/// The reference to the to get the rotation from.
/// The signed rotation Euler angles.
public static Vector3 SignedEulerAngles(this Transform transform)
{
return transform.eulerAngles.UnsignedEulerToSignedEuler();
}
///
/// Gets the signed local Euler angle of the .
///
/// The reference to the to get the local rotation from.
/// The local signed rotation Euler angles.
public static Vector3 SignedLocalEulerAngles(this Transform transform)
{
return transform.localEulerAngles.UnsignedEulerToSignedEuler();
}
}
}