UIEffect
UIEffect copied to clipboard
v3.2.0 Unity 2019.2.0f1 LWRP UICapturedEffectImage doesn't capture during play mode
Currently testing only on PC. On the editor, the capture button does work. However during play mode it doesn't. Gives back a black image. The canvas where the Capture Image component is attached is in screen overlay mode (no 3d no cameras attached for UI).
Let me know what more info would be useful.
Hi @amartinez1660 Thank you for your reporting!
Try to modify UIEffectCapturedImage.cs
(line 360) as following:
// s_CommandBuffer.Blit(BuiltinRenderTextureType.BindableTexture, s_CopyId); // BEFORE
s_CommandBuffer.Blit(BuiltinRenderTextureType.CurrentActive, s_CopyId); // AFTER
To be honest, I don't know if this modify works correctly...
I think the issue is that there's a mix about what constitutes #if UNITY_EDITOR.
Changing line 360 has no effect whether we hit play or not because it's still inside UNITY_EDITOR defines.
I think the issue is more here:
Line block starting at 392,
#if UNITY_EDITOR if (!Application.isPlaying) { Graphics.ExecuteCommandBuffer(s_CommandBuffer); UpdateTexture(); return; } #endif
Because if the application is NOT playing inside the editor, then the coroutine that captures the next frame "_CoUpdateTextureOnNextFrame" which calls UpdateTexture(); won't execute the command buffer:
// Line 542
void UpdateTexture() { #if !UNITY_EDITOR // Execute command buffer. Graphics.ExecuteCommandBuffer (s_CommandBuffer); #endif _Release(false); texture = capturedTexture; _SetDirty(); }
EDIT: Formatting. Can't get the code 'newline' to be visible. Excuse me that.
EDIT2: Just commenting the line at 393 if (!Application.isPlaying)
makes it work during play mode.
Can I do further tests on a couple if devices, would you like me to try that?
@amartinez1660 Thanks. I found that in most environments it doesn't work. I think that UIEffectCapturedImage needs to be completely renovated...
@amartinez1660 Try this script. It works in my environments (Mac editor/Mac standalone/WebGL) with default LWRP asset. UIEffectCapturedImage.cs.zip
unfortunately android is still affected by this