Assets/Deps/emotitron/SmartVars/GenericX.cs
/// <summary>
/// Applies rotation using the correct localRotation/Rotation method, and only applies the axis indicated by the RotationType of the rotation. This allows you to apply an X rotation
/// without changing the y and z values.
/// </summary>
/// <param name="targetTransform"></param>
/// <param name="isLocalRotation"></param>
Applies rotation using the correct localRotation/Rotation method, and only applies the axis indicated by the RotationType of the rotation. This allows you to apply an X rotation
without changing the y and z values.
Applies rotation using the correct localRotation / Rotation method and only applies the axis indicated by the RotationType of the rotation . This allows you to apply an X rotation without changing the y and z values .
public void ApplyRotation(Transform targetTransform, bool isLocalRotation = false)
		{
			if (type == XType.NULL)
			{
				DebugX.LogError("Attempt to apply a null rotation. Skipping.");
				return;
			}
			if (type == XType.Quaternion || type == XType.XYZ)
			{
				if (isLocalRotation)
				{
					targetTransform.localRotation = this;
				}
				else
				{
					targetTransform.rotation = this;
				}
			}
			else
			{
				Vector3 tempvec3 = new Vector3
					(
					(IsX) ? x : (isLocalRotation) ? targetTransform.localEulerAngles.x : targetTransform.eulerAngles.x,
					(IsY) ? y : (isLocalRotation) ? targetTransform.localEulerAngles.y : targetTransform.eulerAngles.y,
					(IsZ) ? z : (isLocalRotation) ? targetTransform.localEulerAngles.z : targetTransform.eulerAngles.z
					);
				if (isLocalRotation)
					targetTransform.eulerAngles = tempvec3;
				else
					targetTransform.localEulerAngles = tempvec3;
			}
		}
public void ApplyRotation ( Transform targetTransform , bool isLocalRotation = false ) { if ( type == XType . NULL ) { DebugX . LogError ( " " ) ; return ; } if ( type == XType . Quaternion || type == XType . XYZ ) { if ( isLocalRotation ) { targetTransform . localRotation = this ; } else { targetTransform . rotation = this ; } } else { Vector3 tempvec3 = new Vector3 ( ( IsX ) ? x : ( isLocalRotation ) ? targetTransform . localEulerAngles . x : targetTransform . eulerAngles . x , ( IsY ) ? y : ( isLocalRotation ) ? targetTransform . localEulerAngles . y : targetTransform . eulerAngles . y , ( IsZ ) ? z : ( isLocalRotation ) ? targetTransform . localEulerAngles . z : targetTransform . eulerAngles . z ) ; if ( isLocalRotation ) targetTransform . eulerAngles = tempvec3 ; else targetTransform . localEulerAngles = tempvec3 ; } }
Applies rotation using the correct localRotation/Rotation method, and only applies the axis indicated by the RotationType of the rotation.
Applies rotation using the correct localRotation / Rotation method and only applies the axis indicated by the RotationType of the rotation .
targetTransform
Transform
None
isLocalRotation
bool
None