UIEffectSnapshot icon indicating copy to clipboard operation
UIEffectSnapshot copied to clipboard

Getting access to RenderTexture in UIEffectSnapshot.CaptureForGlobal callback

Open imurashka opened this issue 1 year ago • 1 comments

I'm trying to get blur without UIEffectSnapshot component, just using API UIEffectSnapshot.CaptureForGlobal. But there is no option to get RenderTexture in callback. The Script usage section says that I need to use UIEffectSnapshot.globalCapturedTexture but it is unpossible bacause it is non-static. So I see two possible options here:

  • Make property UIEffectSnapshot.globalCapturedTexture static
  • Make property UIEffectSnapshotRequest.renderTexture public

For now I'm using reflection as temporary solution:

UIEffectSnapshot.CaptureForGlobal(callback: request =>
{
    var prop = request.GetType().GetProperty("renderTexture", BindingFlags.Instance | BindingFlags.NonPublic);
    source.TrySetResult((RenderTexture)prop.GetValue(request));
});
_blurredTexture = await source.Task;

imurashka avatar Dec 15 '22 12:12 imurashka