Class RuntimeUtility
An ad-hoc collection of helpers, used by Cinemachine or its editor tools in various places
Namespace: Cinemachine
Syntax
[DocumentationSorting(DocumentationSortingAttribute.Level.Undoc)]
public static class RuntimeUtility
Methods
DestroyObject(Object)
Convenience to destroy an object, using the appropriate method depending on whether the game is playing
Declaration
public static void DestroyObject(Object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | obj | The object to destroy |
IsPrefab(GameObject)
Check whether a GameObject is a prefab.
For editor only - some things are disallowed if prefab. In runtime, will always return false.
Declaration
public static bool IsPrefab(GameObject gameObject)
Parameters
| Type | Name | Description |
|---|---|---|
| GameObject | gameObject | the object to check |
Returns
| Type | Description |
|---|---|
| Boolean | If editor, checks if object is a prefab or prefab instance. |
NormalizeCurve(AnimationCurve, Boolean, Boolean)
Normalize a curve so that its X and Y axes range from 0 to 1
Declaration
public static AnimationCurve NormalizeCurve(AnimationCurve curve, bool normalizeX, bool normalizeY)
Parameters
| Type | Name | Description |
|---|---|---|
| AnimationCurve | curve | Curve to normalize |
| Boolean | normalizeX | If true, normalize the X axis |
| Boolean | normalizeY | If true, normalize the Y axis |
Returns
| Type | Description |
|---|---|
| AnimationCurve | The normalized curve |
RaycastIgnoreTag(Ray, out RaycastHit, Single, Int32, in String)
Perform a raycast, but pass through any objects that have a given tag
Declaration
public static bool RaycastIgnoreTag(Ray ray, out RaycastHit hitInfo, float rayLength, int layerMask, in string ignoreTag)
Parameters
| Type | Name | Description |
|---|---|---|
| Ray | ray | The ray to cast |
| RaycastHit | hitInfo | The returned results |
| Single | rayLength | Length of the raycast |
| Int32 | layerMask | Layers to include |
| String | ignoreTag | Tag to ignore |
Returns
| Type | Description |
|---|---|
| Boolean | True if something was hit. Results in hitInfo |
SphereCastIgnoreTag(Vector3, Single, Vector3, out RaycastHit, Single, Int32, in String)
Perform a sphere cast, but pass through objects with a given tag
Declaration
public static bool SphereCastIgnoreTag(Vector3 rayStart, float radius, Vector3 dir, out RaycastHit hitInfo, float rayLength, int layerMask, in string ignoreTag)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | rayStart | Start of the ray |
| Single | radius | Radius of the sphere cast |
| Vector3 | dir | Normalized direction of the ray |
| RaycastHit | hitInfo | Results go here |
| Single | rayLength | Length of the ray |
| Int32 | layerMask | Layers to include |
| String | ignoreTag | Tag to ignore |
Returns
| Type | Description |
|---|---|
| Boolean | True if something is hit. Results in hitInfo. |