Class RuntimeUtility
An ad-hoc collection of helpers, used by Cinemachine or its editor tools in various places
Inherited Members
Namespace: Unity.Cinemachine
Assembly: Unity.Cinemachine.dll
Syntax
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 |
DestroyScratchCollider()
This will destroy the object created by GetScratchCollider() and cause the next call to GetScratchCollider() to create a new cached object.
Declaration
public static void DestroyScratchCollider()
GetScratchCollider()
This is a hidden sphere collider that won't interfere with the scene and can be used for making scratch calculations. It is a single static object that gets created on first demand and recycled on subsequent demands. Call DestroyScratchCollider() to destroy the cached object.
Declaration
public static SphereCollider GetScratchCollider()
Returns
Type | Description |
---|---|
SphereCollider | A cached SphereCollider that will get recycled on subsequent calls. |
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 |
---|---|
bool | If editor, checks if object is a prefab or prefab instance. |
NormalizeCurve(AnimationCurve, bool, bool)
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 |
bool | normalizeX | If true, normalize the X axis |
bool | normalizeY | If true, normalize the Y axis |
Returns
Type | Description |
---|---|
AnimationCurve | The normalized curve |
RaycastIgnoreTag(Ray, out RaycastHit, float, int, 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 |
float | rayLength | Length of the raycast |
int | layerMask | Layers to include |
string | ignoreTag | Tag to ignore |
Returns
Type | Description |
---|---|
bool | True if something was hit. Results in hitInfo |
SphereCastIgnoreTag(Ray, float, out RaycastHit, float, int, in string)
Perform a sphere cast, but pass through objects with a given tag
Declaration
public static bool SphereCastIgnoreTag(Ray ray, float radius, out RaycastHit hitInfo, float rayLength, int layerMask, in string ignoreTag)
Parameters
Type | Name | Description |
---|---|---|
Ray | ray | The ray to cast - this will be the center of the spherecast. |
float | radius | Radius of the sphere cast |
RaycastHit | hitInfo | Results go here |
float | rayLength | Length of the ray |
int | layerMask | Layers to include |
string | ignoreTag | Tag to ignore |
Returns
Type | Description |
---|---|
bool | True if something is hit. Results in hitInfo. |