Camera Shake 1.6.0f1
Reference Manual
Classes | Public Types | Public Member Functions | Static Public Member Functions | Properties | Events | List of all members
CameraShake Class Reference

Shakes the camera and UI. More...

+ Inheritance diagram for CameraShake:
+ Collaboration diagram for CameraShake:

Public Types

enum  ShakeType { CameraMatrix, LocalPosition }
 The type of shake to perform on a camera. More...
 

Public Member Functions

void BeginShakeGUI ()
 Use this at the beginning of an OnGUI call in order to shake OnGUI with Camera Shake. More...
 
void BeginShakeGUILayout ()
 Use this at the beginning of an OnGUI call in order to shake OnGUI with Camera Shake (uses GUILayout). More...
 
void CancelShake ()
 Cancels and resets a camera shake in progress. More...
 
void CancelShake (float time)
 Cancels a camera shake in progress, and resets associated cameras over the specified time, in seconds. More...
 
void EndShakeGUI ()
 Use this at the end of an OnGUI call in order to shake OnGUI with Camera Shake. More...
 
void EndShakeGUILayout ()
 Use this at the end of an OnGUI call in order to shake OnGUI with Camera Shake (uses GUILayout). More...
 
bool IsCancelling ()
 Returns true if the camera is currently cancelling a shake action. More...
 
bool IsShaking ()
 Returns true if the camera is currently shaking. More...
 
void Shake ()
 Shake all cameras associated with this component, using the default settings. More...
 
void Shake (ShakeType shakeType, int numberOfShakes, Vector3 shakeAmount, Vector3 rotationAmount, float distance, float speed, float decay, float uiShakeModifier, bool multiplyByTimeScale)
 Shake all cameras associated with this component, temporarily overriding the default settings. More...
 
void Shake (System.Action callback)
 Shake all cameras associated with this component (using the default settings), then call the specified callback once completed. More...
 
void Shake (ShakeType shakeType, int numberOfShakes, Vector3 shakeAmount, Vector3 rotationAmount, float distance, float speed, float decay, float uiShakeModifier, bool multiplyByTimeScale, System.Action callback)
 Shake all cameras associated with this component (using temporarily overriden settings), then call the specified callback once completed. More...
 

Static Public Member Functions

static void CancelAllShakes ()
 Cancel all camera shakes in progress in the current scene, and reset all cameras. More...
 
static void CancelAllShakes (float time)
 Cancel all camera shakes in progress in the current scene, and reset all cameras over the specified time (in seconds). More...
 
static CameraShake[] GetComponents ()
 Get all enabled Camera Shake components in the scene. More...
 
static void ShakeAll ()
 Shake all cameras associated with all enabled Camera Shake components in the scene, using the default settings. More...
 
static void ShakeAll (ShakeType shakeType, int numberOfShakes, Vector3 shakeAmount, Vector3 rotationAmount, float distance, float speed, float decay, float uiShakeModifier, bool multiplyByTimeScale)
 Shake all cameras associated with all enabled Camera Shake components in the scene, temporarily overriding the default settings. More...
 
static void ShakeAll (System.Action callback)
 Shake all cameras associated with all enabled Camera Shake components in the scene, then call the specified callback once completed. More...
 
static void ShakeAll (ShakeType shakeType, int numberOfShakes, Vector3 shakeAmount, Vector3 rotationAmount, float distance, float speed, float decay, float uiShakeModifier, bool multiplyByTimeScale, System.Action callback)
 Shake all cameras associated with all enabled Camera Shake components in the scene (using temporarily overriden settings), then call the specified callback once completed. More...
 
- Static Public Member Functions inherited from CameraShakeBase
static void Log (object message, string prefix, string type)
 Logs a prefixed message. More...
 
static void Log (object message, string prefix, string type, Object context)
 Logs a prefixed message, with context. More...
 
static void LogError (object message, string prefix, string type)
 Logs a prefixed erorr. More...
 
static void LogError (object message, string prefix, string type, Object context)
 Logs a prefixed exception, with context. More...
 
static void LogException (System.Exception ex)
 Logs an exception. More...
 
static void LogException (System.Exception ex, Object context)
 Logs an exception, with context. More...
 
static void LogWarning (object message, string prefix, string type)
 Logs a prefixed warning. More...
 
static void LogWarning (object message, string prefix, string type, Object context)
 Logs a prefixed warning, with context. More...
 

Properties

List< Camera > cameras [get, set]
 The cameras to shake. More...
 
float decay [get, set]
 The decay speed (between 0 and 1). Higher values will stop shaking sooner. More...
 
float distance [get, set]
 The initial distance for the first shake. More...
 
bool multiplyByTimeScale [get, set]
 If true, multiplies the final shake speed by the time scale. More...
 
int numberOfShakes [get, set]
 The maximum number of shakes to perform. More...
 
Vector3 rotationAmount [get, set]
 The amount to rotate in each direction. More...
 
Vector3 shakeAmount [get, set]
 The amount to shake in each direction. More...
 
ShakeType shakeType [get, set]
 The type of shake to perform (camera matrix or local position). More...
 
float speed [get, set]
 The speed multiplier for the shake. More...
 
float uiShakeModifier [get, set]
 The modifier applied to speed in order to shake the UI. More...
 
Rect uiShakeRect [get, set]
 Gets the current shake area for the UI (in screen space). More...
 

Events

System.Action onEndShaking
 Occurs when a camera has completely stopped shaking and has been reset to its original position. More...
 
System.Action onPostShake
 Occurs after every individual camera shake. More...
 
System.Action onPreShake
 Occurs before every individual camera shake. More...
 
System.Action< Vector3, Quaternion > onShakeOffset
 Occurs before every individual camera movement, with raw positional and rotational offset data. More...
 
System.Action onStartShaking
 Occurs when a camera starts shaking. More...
 

Detailed Description

Shakes the camera and UI.

All events use the System.Action method signature.

Member Enumeration Documentation

enum ShakeType
strong

The type of shake to perform on a camera.

Enumerator
CameraMatrix 

Shakes the camera matrix.

LocalPosition 

Shakes the camera's local position.

Member Function Documentation

void BeginShakeGUI ( )
inline

Use this at the beginning of an OnGUI call in order to shake OnGUI with Camera Shake.

void BeginShakeGUILayout ( )
inline

Use this at the beginning of an OnGUI call in order to shake OnGUI with Camera Shake (uses GUILayout).

static void CancelAllShakes ( )
inlinestatic

Cancel all camera shakes in progress in the current scene, and reset all cameras.

static void CancelAllShakes ( float  time)
inlinestatic

Cancel all camera shakes in progress in the current scene, and reset all cameras over the specified time (in seconds).

Parameters
timeThe amount of time to take to reset the cameras, in seconds. During this time, the camera is smoothly moved back to its original orientation.
void CancelShake ( )
inline

Cancels and resets a camera shake in progress.

void CancelShake ( float  time)
inline

Cancels a camera shake in progress, and resets associated cameras over the specified time, in seconds.

Parameters
timeThe amount of time to take to reset the camera, in seconds. During this time, the camera is smoothly moved back to its original orientation.
void EndShakeGUI ( )
inline

Use this at the end of an OnGUI call in order to shake OnGUI with Camera Shake.

void EndShakeGUILayout ( )
inline

Use this at the end of an OnGUI call in order to shake OnGUI with Camera Shake (uses GUILayout).

static CameraShake [] GetComponents ( )
inlinestatic

Get all enabled Camera Shake components in the scene.

Returns
An array of all enabled Camera Shake components.
bool IsCancelling ( )
inline

Returns true if the camera is currently cancelling a shake action.

Returns
True if the camera is currently cancelling a shake; otherwise false.
bool IsShaking ( )
inline

Returns true if the camera is currently shaking.

Returns
True if the camera is currently shaking; otherwise false.
void Shake ( )
inline

Shake all cameras associated with this component, using the default settings.

void Shake ( ShakeType  shakeType,
int  numberOfShakes,
Vector3  shakeAmount,
Vector3  rotationAmount,
float  distance,
float  speed,
float  decay,
float  uiShakeModifier,
bool  multiplyByTimeScale 
)
inline

Shake all cameras associated with this component, temporarily overriding the default settings.

Parameters
shakeTypeThe type of shake to perform (camera matrix or local position).
numberOfShakesThe maximum number of shakes to perform.
shakeAmountThe amount to shake in each direction.
rotationAmountThe amount to rotate in each axis.
distanceThe initial distance for the first shake.
speedThe speed multiplier for the shake.
decayThe decay speed (between 0 and 1). Higher values will stop shaking sooner.
uiShakeModifierThe modifier applied to speed in order to shake the UI.
multiplyByTimeScaleIf true, multiplies the shake speed by the time scale.
void Shake ( System.Action  callback)
inline

Shake all cameras associated with this component (using the default settings), then call the specified callback once completed.

Parameters
callbackAn action to invoke after the cameras have finished shaking.
void Shake ( ShakeType  shakeType,
int  numberOfShakes,
Vector3  shakeAmount,
Vector3  rotationAmount,
float  distance,
float  speed,
float  decay,
float  uiShakeModifier,
bool  multiplyByTimeScale,
System.Action  callback 
)
inline

Shake all cameras associated with this component (using temporarily overriden settings), then call the specified callback once completed.

Parameters
shakeTypeThe type of shake to perform (camera matrix or local position).
numberOfShakesThe maximum number of shakes to perform.
shakeAmountThe amount to shake in each direction.
rotationAmountThe amount to rotate in each axis.
distanceThe initial distance for the first shake.
speedThe speed multiplier for the shake.
decayThe decay speed (between 0 and 1). Higher values will stop shaking sooner.
uiShakeModifierThe modifier applied to speed in order to shake the UI.
multiplyByTimeScaleIf true, multiplies the shake speed by the time scale.
callbackAn action to invoke after the cameras have finished shaking.
static void ShakeAll ( )
inlinestatic

Shake all cameras associated with all enabled Camera Shake components in the scene, using the default settings.

static void ShakeAll ( ShakeType  shakeType,
int  numberOfShakes,
Vector3  shakeAmount,
Vector3  rotationAmount,
float  distance,
float  speed,
float  decay,
float  uiShakeModifier,
bool  multiplyByTimeScale 
)
inlinestatic

Shake all cameras associated with all enabled Camera Shake components in the scene, temporarily overriding the default settings.

Parameters
shakeTypeThe type of shake to perform (camera matrix or local position).
numberOfShakesThe maximum number of shakes to perform.
shakeAmountThe amount to shake in each direction.
rotationAmountThe amount to rotate in each axis.
distanceThe initial distance for the first shake.
speedThe speed multiplier for the shake.
decayThe decay speed (between 0 and 1). Higher values will stop shaking sooner.
uiShakeModifierThe modifier applied to speed in order to shake the UI.
multiplyByTimeScaleIf true, multiplies the shake speed by the time scale.
static void ShakeAll ( System.Action  callback)
inlinestatic

Shake all cameras associated with all enabled Camera Shake components in the scene, then call the specified callback once completed.

Parameters
callbackAn action to invoke after the cameras have finished shaking.
static void ShakeAll ( ShakeType  shakeType,
int  numberOfShakes,
Vector3  shakeAmount,
Vector3  rotationAmount,
float  distance,
float  speed,
float  decay,
float  uiShakeModifier,
bool  multiplyByTimeScale,
System.Action  callback 
)
inlinestatic

Shake all cameras associated with all enabled Camera Shake components in the scene (using temporarily overriden settings), then call the specified callback once completed.

Parameters
shakeTypeThe type of shake to perform (camera matrix or local position).
numberOfShakesThe maximum number of shakes to perform.
shakeAmountThe amount to shake in each direction.
rotationAmountThe amount to rotate in each axis.
distanceThe initial distance for the first shake.
speedThe speed multiplier for the shake.
decayThe decay speed (between 0 and 1). Higher values will stop shaking sooner.
uiShakeModifierThe modifier applied to speed in order to shake the UI.
multiplyByTimeScaleIf true, multiplies the shake speed by the time scale.
callbackAn action to invoke after the cameras have finished shaking.

Property Documentation

List<Camera> cameras
getset

The cameras to shake.

float decay
getset

The decay speed (between 0 and 1). Higher values will stop shaking sooner.

float distance
getset

The initial distance for the first shake.

bool multiplyByTimeScale
getset

If true, multiplies the final shake speed by the time scale.

int numberOfShakes
getset

The maximum number of shakes to perform.

Vector3 rotationAmount
getset

The amount to rotate in each direction.

Vector3 shakeAmount
getset

The amount to shake in each direction.

ShakeType shakeType
getset

The type of shake to perform (camera matrix or local position).

float speed
getset

The speed multiplier for the shake.

float uiShakeModifier
getset

The modifier applied to speed in order to shake the UI.

Rect uiShakeRect
getset

Gets the current shake area for the UI (in screen space).

Event Documentation

System.Action onEndShaking

Occurs when a camera has completely stopped shaking and has been reset to its original position.

System.Action onPostShake

Occurs after every individual camera shake.

System.Action onPreShake

Occurs before every individual camera shake.

System.Action<Vector3, Quaternion> onShakeOffset

Occurs before every individual camera movement, with raw positional and rotational offset data.

System.Action onStartShaking

Occurs when a camera starts shaking.