Class UnityUiShakeReceiver
Marks UI as something that shakes when a screen-shake effect with "Include UI" enabled plays. Drop it on a UI container (a menu root, HUD, or the Canvas itself) and the screen-shake channel drives it each frame, resetting it when the shake ends.
Render-mode aware: a ScreenSpaceOverlay canvas ignores cameras AND has its root transform driven by
Unity, so when this sits on a root Canvas it shakes the canvas's CHILDREN instead of the (immovable)
root. It re-reads the current children every frame, so content that changes mid-shake (e.g. the menu
being replaced by the gameplay HUD on a scene change) keeps shaking. On any other RectTransform it
shakes itself. Either way it offsets anchoredPosition, which moves UI in every render mode.
Namespace: Serenity.Feedback.Infrastructure.Components
Assembly: Serenity.UnityFeedback.Infrastructure.dll
Syntax
public sealed class UnityUiShakeReceiver : MonoBehaviour
Remarks
Intentionally Unity-only: operates directly on UnityEngine.RectTransform/UnityEngine.Canvas uGUI
concepts (anchored position, render mode, root-canvas detection) that have no portable equivalent.
The abstract shake effect is already the Business-facing contract via IFeedbackChannel; this
component and its companion UiShakeRegistry are just how that effect reaches uGUI.
Constructors
UnityUiShakeReceiver()
Declaration
public UnityUiShakeReceiver()
Methods
ApplyShake(Vector2, float)
Applies a shake offset for this frame. unitOffset is a direction in -1..1;
amplitude is the shake's current (decayed, scaled) magnitude.
Declaration
public void ApplyShake(Vector2 unitOffset, float amplitude)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | unitOffset | |
| float | amplitude |
ResetShake()
Restores the element (or the canvas's children) to the pre-shake position.
Declaration
public void ResetShake()