Skip to content

Commit

Permalink
Update screenshot transparency for Unity 2022
Browse files Browse the repository at this point in the history
  • Loading branch information
katboi01 committed Jan 31, 2025
1 parent 8eadd54 commit 45a1717
Show file tree
Hide file tree
Showing 5 changed files with 1,454 additions and 10 deletions.
10 changes: 3 additions & 7 deletions Assets/Scripts/Screenshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private IEnumerator RecordGif(int width, int height, bool transparent, int quali
UmaViewerUI.Instance.GifSlider.value = (float)frame / clipFrameCount;
UmaViewerUI.Instance.AnimationProgressChange((float)frame / clipFrameCount);
yield return new WaitForEndOfFrame();
var tex = GrabFrame(camera, width, height, transparent, transparent);
var tex = GrabFrame(camera, width, height, transparent);
CaptureToGIFCustom.Instance.Frames.Add(new Image(tex));
Destroy(tex);
frame++;
Expand All @@ -92,7 +92,7 @@ private IEnumerator RecordGif(int width, int height, bool transparent, int quali
UmaViewerUI.Instance.GifSlider.value = 1;
}

public static Texture2D GrabFrame(Camera cam, int width, int height, bool transparent = true, bool gifBackground = false)
public static Texture2D GrabFrame(Camera cam, int width, int height, bool transparent = true)
{
var dimensions = GetResolution(width, height);
width = dimensions.x;
Expand All @@ -103,15 +103,11 @@ public static Texture2D GrabFrame(Camera cam, int width, int height, bool transp
Color oldBG = cam.backgroundColor;

cam.cullingMask = ~LayerMask.GetMask("UI");
if (gifBackground)
if (transparent)
{
cam.clearFlags = CameraClearFlags.SolidColor;
cam.backgroundColor = new Color32(0, 0, 0, 0);
}
else if (transparent)
{
cam.clearFlags = CameraClearFlags.Depth;
}

var tex_color = new Texture2D(width, height, TextureFormat.ARGB32, false);
int aaLevel = QualitySettings.antiAliasing == 0? 1 : QualitySettings.antiAliasing; //RT uses '1' for no antialiasing
Expand Down
4 changes: 2 additions & 2 deletions ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ PlayerSettings:
loadStoreDebugModeEnabled: 0
visionOSBundleVersion: 1.0
tvOSBundleVersion: 1.0
bundleVersion: 2.1.22
bundleVersion: 2.1.23
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down Expand Up @@ -755,7 +755,7 @@ PlayerSettings:
PS5: UNITY_POST_PROCESSING_STACK_V2
QNX: UNITY_POST_PROCESSING_STACK_V2
Stadia: UNITY_POST_PROCESSING_STACK_V2
Standalone: UNITY_POST_PROCESSING_STACK_V2
Standalone: UNITY_POST_PROCESSING_STACK_V2;AMPLIFY_SHADER_EDITOR
VisionOS: UNITY_POST_PROCESSING_STACK_V2
WebGL: UNITY_POST_PROCESSING_STACK_V2
XboxOne: UNITY_POST_PROCESSING_STACK_V2
Expand Down
Loading

0 comments on commit 45a1717

Please sign in to comment.