Capture a screenshot with effect and display it. Light-weight, non-realtime, no-camera (and no-PostProcessingStack), but be effective enough. The captured snapshot can be used as a background for a UI panel.
<< Description | Demo | Installation | Usage | Change log >>
Do you like blurred backgrounds, like iOS home screen? Blurring effect is easy to implement in Unity.
_GrabTexture
with blur-algorithms.Alternatively, you can use PostProcessingStack package.
However, this method requires some caution to be used as a UI.
Screen Space - Overlay
is not supported.This package uses static screen content of one frame instead of real-time screen content to provide a very light screen blur.
The movement will disappear from the background, but it will be enough to use it as a background for panels, dialog windows and menus.
Objects that are further back than the background are (consequently) invisible. Disabling their animations or hiding them would improve performance and power consumption.
PostProcessingStack
are needed.Screen Space - Overlay
and Screen Space - Camera
World Space - Camera
This package is available on OpenUPM. You can install it via openupm-cli.
openupm add com.coffee.ui-effect-snapshot
Find the manifest.json file in the Packages folder of your project and edit it to look like this:
{
"dependencies": {
"com.coffee.ui-effect-snapshot": "https://github.com/mob-sakai/UIEffectSnapshot.git",
...
},
}
To update the package, change suffix #{version}
to the target version.
"com.coffee.ui-effect-snapshot": "https://github.com/mob-sakai/UIEffectSnapshot.git#1.0.0",
Or, use UpmGitExtension to install and update the package.
Game Object/UI/Effect Snapshot
to create.Capture
or Release
button in the inspector to preview the snapshot.Properties | Screenshot |
---|---|
Effect Mode: Grayscale, Sepia, Nega, Pixelation Color Mode: Multiply, Fill, Additive, Subtract Blur Mode: Fast, Medium, Detail Custom Materials: Additional image effect material. The built-ins include Vignette, Distortion, Noise, Scanning line, RGB Shift. Global Mode: Use a global image instead of an instance image. Capture On Enable: When the component is enable, capture screen automatically.Fit To Screen: Fit transform to the root canvas on enable/captured. Reduction Rate: Reduce the size of the intermediate buffer used to render effects. Down Sampling Rate: Reduce the size of the result RenderTexture. |
// Add UIEffectSnapshot instance at runtime.
uiEffectSnapshot = gameObject.AddComponent<UIEffectSnapshot>();
// Capture a screenshot for instance.
uiEffectSnapshot.Capture(callback: request => { Debug.Log("Captured"); });
// Capture a screenshot for global.
// You can capture screen in cases where there is no UIEffectSnapshot instance.
// The captured image will be used with 'Global Mode' instance.
// Or, you can use 'UIEffectSnapshot.globalCapturedTexture' property to get it.
UIEffectSnapshot.CaptureForGlobal(callback: request => { Debug.Log("Captured"); });
New
button in inspector and save the material into the project.Capture
button to preview the custom effect.Game Object/UI/UI Effect Snapshot Panel/***
to create a panel with snapshot preset.Show
or Hide
button in the inspector to preview the snapshot.Properties | Screenshot |
---|---|
Snapshots: UIEffectSnapshot instances to control. Press Refresh button to set children snapshots. Transition Duration: Duration of show/hide transition. Show On Enable: When the component is enable, show the panel automatically. Deactivate On Hidden: When the component is hidden, deactivate the gameObject automatically. |
// Show/Hide the panel with snapshot.
// Before capturing, CanvasGroup.alpha will be set to 0 and capture the screen except for the panel.
panel.Show(callback: request => { Debug.Log("Shown"); });
panel.Hide(callback: request => { Debug.Log("Hidden"); });
Package Manager
windowUI Effect Snapshot
package in package listImport Sample
buttonAssets/Samples/UI Effect Snapshot/{version}/Demo
UIEffectSnapshot_Demo
scene and play itAssets/Samples/UI Effect Snapshot Demo
from menuAssets/Samples/UI Effect Snapshot/{version}/Demo
UIEffectSnapshot_Demo
scene and play itRotationCube.mat
in Assets
and select all sub-assets.Universal Render Pipeline/Lit
.Issues are very valuable to this project.
Pull requests are, a great way to get your ideas into this repository. See CONTRIBUTING.md.
This is an open source project that I am developing in my spare time. If you like it, please support me. With your support, I can spend more time on development. :)