TransformExtensions Class Reference

Class providing some extended function that help perform certain tasks with Unity's Transforms.

Static Public Member Functions

static IEnumerable< Transform > AllDecendants (this Transform transform, bool groupByLevel=true)
 Extension provided to enable for-each through all descendants, rather than just children.
 
static List< Transform > AllDecendantsList (this Transform transform, bool groupByLevel=true)
 Return a List of transforms that are all the descendants of the calling transform.
 
static void AllDecendantsList (this Transform transform, ref List< Transform > list, bool groupByLevel=true)
 Appends to the provided list, references to transforms that are all the descendants of the calling transform.
 
static void CopyFrom (this Transform destination, Transform sourceTransform, bool SrcWorldNotLocal)
 Copies local or global TRS values from the source transform, into the calling (this), destination transform's local values
 
static void CopyTo (this Transform transform, Transform destination, bool SrcWorldNotLocal)
 Copies local or global TRS values from the source transform (this), into the destination transform's local values
 
static void DebugDrawLine (Vector3 start, Vector3 end, Transform world)
 Utility functions, draws a debugLine, transformed by the provided world transform
 
static bool IsDecendantOf (this Transform transform, Transform transformToCheck)
 Check if a particular transform is a descendant of another transform.
 
static void LerpPosition (this Transform transform, Vector3 finalPosition, float fraction)
 Convenience function used to get, lerp, and set the transform's position
 
static void LerpRotation (this Transform transform, Quaternion finalRotation, float fraction)
 Convenience function used to get, lerp, and set the transform's rotation
 
static void LerpScale (this Transform transform, Vector3 finalSclae, float fraction)
 Convenience function used to get, lerp, and set the transform's scale
 
static Vector2 RoateAboutPoint (this Vector2 pointToRotate, Vector2 centerPoint, float angle)
 compute rotation of a 2d point, about an arbitrary 2d point
 
static void SetToUnity (this Transform transform)
 Similar to Reset, but a little clearer, and only effects transformation values. A utility function, resets all values of the transform to Unity/Identity.
 
static string ToStringEyE (this Transform transform, bool includeDecendants=false)
 Output transform as single line string, useful for debugging.
 
static string ToStringEyE (this Transform transform, string indent, bool includeDecendants=false)
 Output transform as multi-line, indented by descendant, string, useful for debugging.
 
static IEnumerable< Transform > TransformAndAllDecendants (this Transform transform)
 Extension provided to enable for-each through transform and all descendants, rather than just children.
 
static Bounds TransformBoundsRelativeToAncestor (this Transform transform, Transform ancenstorTransform, Bounds bounds)
 utility function that applies only the transforms relative to a parent (or earlier ancestor), to the provided bounds. Rotation and Scaling only.
 
static Bounds TransformBoundsRelativeToAncestorViaIteration (this Transform transform, Transform ancenstorTransform, Bounds bounds)
 This version exists soles as a sanity check for the above method
 
static Vector3 TransformDirectionRelativeToAncestor (this Transform transform, Transform ancenstorTransform, Vector3 point)
 utility function that applies only the transforms relative to an parent or earlier ancestor to the provided point. rotation only
 
static Vector3 TransformPointLocalOnly (this Transform transform, Vector3 point)
 utility function that applies only the transforms LOCAL transformation values to the provided point. Parent transforms are ignored.
 
static Vector3 TransformPointRelativeToAncestor (this Transform transform, Transform ancenstorTransform, Vector3 point)
 utility function that applies only the transforms relative to an parent or earlier ancestor to the provided point.
 
static Matrix4x4 TransformRelativeToAncestor (this Transform transform, Transform ancenstorTransform)
 Computes a transformation, relative to an ancestor transform, as a Metrix4x4.
 
static Vector3 TransformVectorRelativeToAncestor (this Transform transform, Transform ancenstorTransform, Vector3 point)
 utility function that applies only the transforms relative to an parent or earlier ancestor to the provided point. rotation only
 
static Vector2 Vector2FromAngle (float angle)
 Returns the point on the circumference of a 1 unit radius circle, at the angle provided. An angle of zero results in (1,0).