![]() |
Infohazard.Core 1.4.1
Infohazard Core Utility Library
|
Contains utility methods for dealing with GameObjects and Transforms. More...
Static Public Member Functions | |
static void | GetCapsuleInfo (float radius, float height, Vector3 center, int direction, Transform transform, out Vector3 point1, out Vector3 point2, out float worldRadius, out float worldHeight) |
Converts capsule info in transform/height/radius form to two-point form for use with Physics.CapsuleCast. More... | |
static void | GetCapsuleInfo (this CharacterController capsule, out Vector3 point1, out Vector3 point2, out float worldRadius, out float worldHeight) |
Converts capsule info in a CharacterController to two-point form for use with Physics.CapsuleCast. More... | |
static void | GetCapsuleInfo (this CapsuleCollider capsule, out Vector3 point1, out Vector3 point2, out float worldRadius, out float worldHeight) |
Converts capsule info in a CapsuleCollider to two-point form for use with Physics.CapsuleCast. More... | |
static bool | ColliderCast (this Collider collider, float padding, Vector3 direction, out RaycastHit hit, float maxDistance=float.PositiveInfinity, int layerMask=Physics.DefaultRaycastLayers, QueryTriggerInteraction triggerInteraction=QueryTriggerInteraction.UseGlobal) |
Perform a physics cast depending on the type of collider, using its parameters. Only BoxCollider, SphereCollider, and CapsuleCollider are supported. For simplicity, the scale of the transform is assumed to be uniform. More... | |
static void | SetParentAndReset (this Transform transform, Transform parent) |
Set the parent of the given transform, and reset it's local position, rotation, and scale. More... | |
static void | Initialize (this Transform transform, Transform parent, Vector3? position=null, Quaternion? rotation=null, Vector3? scale=null, bool inWorldSpace=false, in Scene? scene=null) |
Initialize the transform with the given parent, position, rotation, and scale. More... | |
static void | Initialize (this Transform transform, in SpawnParams spawnParams=default) |
Initialize the transform with the given spawn params. More... | |
static void | Initialize (this Transform transform, Vector3? position=null, Quaternion? rotation=null, Vector3? scale=null) |
Set's the transform's position, and rotation, and scale (if they are specified). More... | |
static void | DestroyChildren (this Transform transform) |
Destroy all of the child GameObjects of a Transform at the end of this frame. More... | |
static void | DestroyChildrenImmediate (this Transform transform) |
Destroy all of the child GameObjects of a Transform immediately. More... | |
static void | DespawnChildren (this Transform transform) |
Despawn all of the child GameObjects of a Transform. More... | |
static bool | TryGetComponentInParent< T > (this GameObject obj, out T result) |
Like GetComponentInParent, but more convenient if using in conditionals and also using the component value. More... | |
static bool | TryGetComponentInChildren< T > (this GameObject obj, out T result, bool includeInactive=false) |
Like GetComponentInChildren, but more convenient if using in conditionals and also using the component value. More... | |
static bool | TryGetComponentInParent< T > (this Component cmp, out T result) |
Like GetComponentInParent, but more convenient if using in if statements and also using the component value. More... | |
static bool | TryGetComponentInChildren< T > (this Component cmp, out T result) |
Like GetComponentInChildren, but more convenient if using in if statements and also using the component value. More... | |
static string | GetRelativeTransformPath (this Transform from, Transform to) |
Get the path from one transform to another (object names separated by slashes). Names are URL encoded in case they contain slashes. More... | |
static Transform | GetTransformAtRelativePath (this Transform from, string path) |
Parses a slash-separated Transform path from a parent object to find a child. The names are expected to be URL encoded. More... | |
static bool | IsPathUnique (this Transform from, Transform to) |
Check whether the path from one transform to another (the one returned by GetRelativeTransformPath) is unique. If the path is not unique, using GetTransformAtRelativePath will not necessarily return the correct transform. More... | |
static bool | IsNameUniqueInSiblings (this Transform transform) |
Return whether the name of an object is unique within its siblings. More... | |
static void | SetLayerRecursively (this GameObject obj, int layer) |
Sets the layer of a GameObject and all of its children. More... | |
static void | SetLinearVelocity (this Rigidbody rb, Vector3 velocity) |
Utility method to accommodate Unity 6 velocity name change. More... | |
static Vector3 | GetLinearVelocity (this Rigidbody rb) |
Utility method to accommodate Unity 6 velocity name change. More... | |
static void | AddLinearVelocity (this Rigidbody rb, Vector3 velocity) |
Utility method to accommodate Unity 6 velocity name change. More... | |
static void | MoveTowardsLinearVelocity (this Rigidbody rb, Vector3 targetVelocity, float maxDeltaV) |
Utility method to accommodate Unity 6 velocity name change. More... | |
Contains utility methods for dealing with GameObjects and Transforms.
|
static |
Utility method to accommodate Unity 6 velocity name change.
|
static |
Perform a physics cast depending on the type of collider, using its parameters. Only BoxCollider, SphereCollider, and CapsuleCollider are supported. For simplicity, the scale of the transform is assumed to be uniform.
collider | The BoxCollider, SphereCollider, or CapsuleCollider to cast from. |
padding | A padding to reduce the collider's extents. Given in world units. |
direction | Direction to cast in. |
hit | The hit information. |
maxDistance | The maximum distance to cast. Default is infinity. |
layerMask | The layer mask to cast against. Default is default raycast layers. |
triggerInteraction | Whether to include triggers. Default is use global settings. |
|
static |
Despawn all of the child GameObjects of a Transform.
transform | Transform to despawn children of. |
|
static |
Destroy all of the child GameObjects of a Transform at the end of this frame.
transform | Transform to destroy children of. |
|
static |
Destroy all of the child GameObjects of a Transform immediately.
transform | Transform to destroy children of. |
|
static |
Converts capsule info in transform/height/radius form to two-point form for use with Physics.CapsuleCast.
Also tells you the radius and height of the capsule in world space.
radius | Radius of the capsule in local space. |
height | Height of the capsule in local space. |
center | Center of the capsule in local space. |
direction | On which axis the capsule extends (0 = x, 1 = y, 2 = z). |
transform | Transform that the capsule is parented to. |
point1 | The first point of the capsule in world space. |
point2 | The second point of the capsule in world space. |
worldRadius | The radius of the capsule in world space. |
worldHeight | The height of the capsule in world space. |
|
static |
Converts capsule info in a CapsuleCollider to two-point form for use with Physics.CapsuleCast.
Also tells you the radius and height of the capsule in world space.
capsule | The CapsuleCollider to read. |
point1 | The first point of the capsule in world space. |
point2 | The second point of the capsule in world space. |
worldRadius | The radius of the capsule in world space. |
worldHeight | The height of the capsule in world space. |
|
static |
Converts capsule info in a CharacterController to two-point form for use with Physics.CapsuleCast.
Also tells you the radius and height of the capsule in world space.
capsule | The CharacterController to read. |
point1 | The first point of the capsule in world space. |
point2 | The second point of the capsule in world space. |
worldRadius | The radius of the capsule in world space. |
worldHeight | The height of the capsule in world space. |
|
static |
Utility method to accommodate Unity 6 velocity name change.
|
static |
Get the path from one transform to another (object names separated by slashes). Names are URL encoded in case they contain slashes.
The parameter to must be a direct descendent of from, or an error is logged. The returned path contains the name of to but not from. This path can be turned back to an object reference using GetTransformAtRelativePath.
from | The parent Transform to get the path from. |
to | The Transform to get the path to. |
|
static |
Parses a slash-separated Transform path from a parent object to find a child. The names are expected to be URL encoded.
This can be used to turn a path created by GetRelativeTransformPath back to an object reference.
from | The parent Transform to search from. |
path | The slash-separated path to search for. |
|
static |
Initialize the transform with the given spawn params.
transform | The transform to initialize. |
spawnParams | The spawn parameters. |
|
static |
Initialize the transform with the given parent, position, rotation, and scale.
transform | The transform to initialize. |
parent | The parent to attach to. |
position | The position (if null, do not set). |
rotation | The rotation (if null, do not set). |
scale | The scale (if null, do not set). |
inWorldSpace | Whether the given position, rotation, and scale should be considered global. |
scene | An optional scene to move the object to. |
|
static |
Set's the transform's position, and rotation, and scale (if they are specified).
transform | The transform to initialize. |
position | The position (if null, do not set). |
rotation | The rotation (if null, do not set). |
scale | The scale (if null, do not set). |
|
static |
Return whether the name of an object is unique within its siblings.
transform | The object to check. |
|
static |
Check whether the path from one transform to another (the one returned by GetRelativeTransformPath) is unique. If the path is not unique, using GetTransformAtRelativePath will not necessarily return the correct transform.
The names of the objects do not need to be globally unique. Rather, they must be unique within all of their siblings according to IsNameUniqueInSiblings.
from | The transform to check the path from. |
to | The transform to check the path to. |
|
static |
Utility method to accommodate Unity 6 velocity name change.
|
static |
Sets the layer of a GameObject and all of its children.
obj | The GameObject to set the layer on. |
layer | The layer index to set. |
|
static |
Utility method to accommodate Unity 6 velocity name change.
|
static |
Set the parent of the given transform, and reset it's local position, rotation, and scale.
transform | The transform to reset. |
parent | The transform to parent it to (can be null). |
|
static |
Like GetComponentInChildren, but more convenient if using in if statements and also using the component value.
|
static |
Like GetComponentInChildren, but more convenient if using in conditionals and also using the component value.
|
static |
Like GetComponentInParent, but more convenient if using in if statements and also using the component value.
|
static |
Like GetComponentInParent, but more convenient if using in conditionals and also using the component value.
obj | The object to search from. |
result | The found component or null. |
T | The type of component to search for. |