Shaking the UI with Camera Shake

Camera Shake supports shaking the user interface in a few different ways. The following instructions here may differ, depending on what UI solution is being used.

Shaking a UI with a dedicated camera (Unity UI in Screen Space - Camera or World Space)

If the UI solution you are using has a dedicated camera, just add that camera to Camera Shake's list of cameras. You may need to use local position shaking instead of the camera matrix, depending on the UI solution.

Shaking a screen space UI without a camera (Unity UI in Screen Space - Overlay)

This is not supported directly by Camera Shake - in order to shake these you will need to modify the position of the UI using the value from the uiShakeRect property on the Camera Shake component.

Shaking OnGUI (legacy)

To shake anything in OnGUI, use the following methods on the Camera Shake component at the start and end of your OnGUI callback:

  • BeginShakeGUI() and EndShakeGUI() - use these when not using the automatic layout system.
  • BeginShakeGUILayout() and EndShakeGUILayout() - use these when using the automatic layout system.

Still need help? Contact Us Contact Us