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.
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.
Shaking a UI with a dedicated camera (Unity UI in Screen or World Space, NGUI, etc.)
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 mode, GUITextures, etc.)
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.