Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting access to RenderTexture in UIEffectSnapshot.CaptureForGlobal callback #7

Open
imurashka opened this issue Dec 15, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@imurashka
Copy link

imurashka commented Dec 15, 2022

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
Copy link
Author

I added pull request with both changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants