Class TransformUtilities
Contains many utility functions related to transforms
Namespace: WeaverCore.Utilities
Assembly: WeaverCore.dll
Syntax
public static class TransformUtilities
Methods
| Edit this page View SourceGetHashOfTransform(Transform, bool)
Gets a hash of the transform and it's hiearchy
Declaration
public static int GetHashOfTransform(Transform transform, bool includeChildren = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | The transform to check |
| bool | includeChildren | Should child objects also be included in the hash? |
Returns
| Type | Description |
|---|---|
| int | Returns the hash of the transform's hiearchy |
GetLocalScaleXY(Transform)
Gets the local scale of the transform in the XY plane.
Declaration
public static Vector2 GetLocalScaleXY(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | The transform to retrieve the local scale from. |
Returns
| Type | Description |
|---|---|
| Vector2 | The local scale of the transform in the XY plane. |
GetXLocalPosition(Transform)
Gets the local x position of a transform
Declaration
public static float GetXLocalPosition(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform |
Returns
| Type | Description |
|---|---|
| float |
GetXLocalRotation(Transform)
Gets the local x rotation of a transform
Declaration
public static float GetXLocalRotation(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform |
Returns
| Type | Description |
|---|---|
| float |
GetXLocalScale(Transform)
Gets the local x scale of a transform
Declaration
public static float GetXLocalScale(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform |
Returns
| Type | Description |
|---|---|
| float |
GetXPosition(Transform)
Gets the x position of a transform
Declaration
public static float GetXPosition(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform |
Returns
| Type | Description |
|---|---|
| float |
GetXRotation(Transform)
Gets the x rotation of a transform
Declaration
public static float GetXRotation(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform |
Returns
| Type | Description |
|---|---|
| float |
GetYLocalPosition(Transform)
Gets the local y position of a transform
Declaration
public static float GetYLocalPosition(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform |
Returns
| Type | Description |
|---|---|
| float |
GetYLocalRotation(Transform)
Gets the local y rotation of a transform
Declaration
public static float GetYLocalRotation(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform |
Returns
| Type | Description |
|---|---|
| float |
GetYLocalScale(Transform)
Gets the local y scale of a transform
Declaration
public static float GetYLocalScale(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform |
Returns
| Type | Description |
|---|---|
| float |
GetYPosition(Transform)
Gets the y position of a transform
Declaration
public static float GetYPosition(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform |
Returns
| Type | Description |
|---|---|
| float |
GetYRotation(Transform)
Gets the y rotation of a transform
Declaration
public static float GetYRotation(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform |
Returns
| Type | Description |
|---|---|
| float |
GetZLocalPosition(Transform)
Gets the local z position of a transform
Declaration
public static float GetZLocalPosition(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform |
Returns
| Type | Description |
|---|---|
| float |
GetZLocalRotation(Transform)
Gets the local z rotation of a transform
Declaration
public static float GetZLocalRotation(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform |
Returns
| Type | Description |
|---|---|
| float |
GetZLocalScale(Transform)
Gets the local z scale of a transform
Declaration
public static float GetZLocalScale(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform |
Returns
| Type | Description |
|---|---|
| float |
GetZPosition(Transform)
Gets the z position of a transform
Declaration
public static float GetZPosition(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform |
Returns
| Type | Description |
|---|---|
| float |
GetZRotation(Transform)
Gets the z rotation of a transform
Declaration
public static float GetZRotation(this Transform transform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform |
Returns
| Type | Description |
|---|---|
| float |
JitterObject(GameObject, Vector3, float)
Will rapidly jitter an object until the coroutine gets cancelled
Declaration
public static IEnumerator JitterObject(GameObject gameObject, Vector3 amount, float jitterFPS = Infinity)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | gameObject | The object to jitter |
| Vector3 | amount | The amount of jitter to be applied |
| float | jitterFPS | How fast the jitter should be applied |
Returns
| Type | Description |
|---|---|
| IEnumerator |
JitterObject(Transform, Vector3, float)
Will rapidly jitter an object until the coroutine gets cancelled
Declaration
public static IEnumerator JitterObject(Transform transform, Vector3 amount, float jitterFPS = Infinity)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | The transform to jitter |
| Vector3 | amount | The amount of jitter to be applied |
| float | jitterFPS | How fast the jitter should be applied |
Returns
| Type | Description |
|---|---|
| IEnumerator |
SetLocalPosition(Transform, float, float, float)
Sets the local position of the transform
Declaration
public static Vector3 SetLocalPosition(this Transform transform, float x = NaN, float y = NaN, float z = NaN)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | The transform to set |
| float | x | The new local x-position to set. If it's set to NaN, it will leave it unchanged |
| float | y | The new local y-position to set. If it's set to NaN, it will leave it unchanged |
| float | z | The new local z-position to set. If it's set to NaN, it will leave it unchanged |
Returns
| Type | Description |
|---|---|
| Vector3 | Returns the new local position that has just been set |
SetLocalRotation(Transform, float, float, float)
Sets the local rotation of the transform
Declaration
public static Vector3 SetLocalRotation(this Transform transform, float x = NaN, float y = NaN, float z = NaN)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | The transform to set |
| float | x | The new local x-rotation to set. If it's set to NaN, it will leave it unchanged |
| float | y | The new local y-rotation to set. If it's set to NaN, it will leave it unchanged |
| float | z | The new local z-rotation to set. If it's set to NaN, it will leave it unchanged |
Returns
| Type | Description |
|---|---|
| Vector3 | Returns the new local rotation that has just been set |
SetLocalScaleXY(Transform, float, float)
Sets the local scale of the transform in the XY plane using individual components.
Declaration
public static void SetLocalScaleXY(this Transform transform, float x, float y)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | The transform to set the local scale for. |
| float | x | The new local scale along the X-axis. |
| float | y | The new local scale along the Y-axis. |
SetLocalScaleXY(Transform, Vector2)
Sets the local scale of the transform in the XY plane.
Declaration
public static void SetLocalScaleXY(this Transform transform, Vector2 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | The transform to set the local scale for. |
| Vector2 | value | The new local scale in the XY plane. |
SetPosition(Transform, float, float, float)
Sets the position of the transform
Declaration
public static Vector3 SetPosition(this Transform transform, float x = NaN, float y = NaN, float z = NaN)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | The transform to set |
| float | x | The new x-position to set. If it's set to NaN, it will leave it unchanged |
| float | y | The new y-position to set. If it's set to NaN, it will leave it unchanged |
| float | z | The new z-position to set. If it's set to NaN, it will leave it unchanged |
Returns
| Type | Description |
|---|---|
| Vector3 | Returns the new position that has just been set |
SetRotation(Transform, float, float, float)
Sets the rotation of the transform
Declaration
public static Vector3 SetRotation(this Transform transform, float x = NaN, float y = NaN, float z = NaN)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | The transform to set |
| float | x | The new x-rotation to set. If it's set to NaN, it will leave it unchanged |
| float | y | The new y-rotation to set. If it's set to NaN, it will leave it unchanged |
| float | z | The new z-rotation to set. If it's set to NaN, it will leave it unchanged |
Returns
| Type | Description |
|---|---|
| Vector3 | Returns the new rotation that has just been set |
SetXLocalPosition(Transform, float)
Sets the local x position of a transform
Declaration
public static float SetXLocalPosition(this Transform transform, float newX)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | |
| float | newX |
Returns
| Type | Description |
|---|---|
| float |
SetXLocalRotation(Transform, float)
Sets the local x rotation of a transform
Declaration
public static float SetXLocalRotation(this Transform transform, float newX)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | |
| float | newX |
Returns
| Type | Description |
|---|---|
| float |
SetXLocalScale(Transform, float)
Sets the local x scale of a transform
Declaration
public static float SetXLocalScale(this Transform transform, float newX)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | |
| float | newX |
Returns
| Type | Description |
|---|---|
| float |
SetXPosition(Transform, float)
Sets the x position of a transform
Declaration
public static float SetXPosition(this Transform transform, float newX)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | |
| float | newX |
Returns
| Type | Description |
|---|---|
| float |
SetXRotation(Transform, float)
Sets the x rotation of a transform
Declaration
public static float SetXRotation(this Transform transform, float newX)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | |
| float | newX |
Returns
| Type | Description |
|---|---|
| float |
SetYLocalPosition(Transform, float)
Sets the local y position of a transform
Declaration
public static float SetYLocalPosition(this Transform transform, float newY)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | |
| float | newY |
Returns
| Type | Description |
|---|---|
| float |
SetYLocalRotation(Transform, float)
Sets the local y rotation of a transform
Declaration
public static float SetYLocalRotation(this Transform transform, float newY)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | |
| float | newY |
Returns
| Type | Description |
|---|---|
| float |
SetYLocalScale(Transform, float)
Sets the local y scale of a transform
Declaration
public static float SetYLocalScale(this Transform transform, float newY)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | |
| float | newY |
Returns
| Type | Description |
|---|---|
| float |
SetYPosition(Transform, float)
Sets the y position of a transform
Declaration
public static float SetYPosition(this Transform transform, float newY)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | |
| float | newY |
Returns
| Type | Description |
|---|---|
| float |
SetYRotation(Transform, float)
Sets the y rotation of a transform
Declaration
public static float SetYRotation(this Transform transform, float newY)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | |
| float | newY |
Returns
| Type | Description |
|---|---|
| float |
SetZLocalPosition(Transform, float)
Sets the local z position of a transform
Declaration
public static float SetZLocalPosition(this Transform transform, float newZ)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | |
| float | newZ |
Returns
| Type | Description |
|---|---|
| float |
SetZLocalRotation(Transform, float)
Sets the local z rotation of a transform
Declaration
public static float SetZLocalRotation(this Transform transform, float newZ)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | |
| float | newZ |
Returns
| Type | Description |
|---|---|
| float |
SetZLocalScale(Transform, float)
Sets the local z scale of a transform
Declaration
public static float SetZLocalScale(this Transform transform, float newZ)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | |
| float | newZ |
Returns
| Type | Description |
|---|---|
| float |
SetZPosition(Transform, float)
Sets the z position of a transform
Declaration
public static float SetZPosition(this Transform transform, float newZ)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | |
| float | newZ |
Returns
| Type | Description |
|---|---|
| float |
SetZRotation(Transform, float)
Sets the z rotation of a transform
Declaration
public static float SetZRotation(this Transform transform, float newZ)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | |
| float | newZ |
Returns
| Type | Description |
|---|---|
| float |
SpawnRandomObjects(GameObject, Vector3, int, int, float, float, float, float, Vector2)
Spawns a bunch of new objects. The quantity, rigidbody velocity, velocity angle, and spawn origin are all randomized
Declaration
public static GameObject[] SpawnRandomObjects(GameObject obj, Vector3 spawnPoint, int quantityMin, int quantityMax, float minVelocity, float maxVelocity, float angleMin, float angleMax, Vector2 originOffset = default)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | obj | The object to spawn |
| Vector3 | spawnPoint | The place where all the objects will spawn |
| int | quantityMin | The minimum amount of objects to spawn |
| int | quantityMax | The maximum amount of objects to spawn |
| float | minVelocity | The minimum velocity to be applied to each object |
| float | maxVelocity | The maximum amount of velocity to be applied to each object |
| float | angleMin | The minimum velocity angle to be applied to each object |
| float | angleMax | The maximum velocity angle to be applied to each object |
| Vector2 | originOffset | How far away can objects spawn from the |
Returns
| Type | Description |
|---|---|
| GameObject[] | Returns a list of all the objects that have been spawned |
SpawnRandomObjects(ObjectPool, Vector3, int, int, float, float, float, float, Vector2)
Spawns a bunch of new objects. The quantity, rigidbody velocity, velocity angle, and spawn origin are all randomized
Declaration
public static GameObject[] SpawnRandomObjects(ObjectPool pool, Vector3 spawnPoint, int quantityMin, int quantityMax, float minVelocity, float maxVelocity, float angleMin, float angleMax, Vector2 originOffset = default)
Parameters
| Type | Name | Description |
|---|---|---|
| ObjectPool | pool | The pool to spawn the objects from |
| Vector3 | spawnPoint | The place where all the objects will spawn |
| int | quantityMin | The minimum amount of objects to spawn |
| int | quantityMax | The maximum amount of objects to spawn |
| float | minVelocity | The minimum velocity to be applied to each object |
| float | maxVelocity | The maximum amount of velocity to be applied to each object |
| float | angleMin | The minimum velocity angle to be applied to each object |
| float | angleMax | The maximum velocity angle to be applied to each object |
| Vector2 | originOffset | How far away can objects spawn from the |
Returns
| Type | Description |
|---|---|
| GameObject[] | Returns a list of all the objects that have been spawned |