Skip to content

Commit

Permalink
feat(General): update keybaord shortcut for Screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
seeyam-q committed Jul 14, 2024
1 parent ac2beb6 commit 302c52c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion General/Runtime/FortySevenE.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:f06555f75b070af458a003d92f9efb00",
"GUID:d8b63aba1907145bea998dd612889d6b",
"GUID:2665a8d13d1b3f18800f46e256720795"
"GUID:2665a8d13d1b3f18800f46e256720795",
"GUID:75469ad4d38634e559750d17036d5f7c"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
17 changes: 16 additions & 1 deletion General/Runtime/Screenshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,20 @@ public class Screenshot : MonoBehaviour

private void Update()
{
if (Input.GetKeyDown(KeyCode.P))
#if ENABLE_INPUT_SYSTEM
if (UnityEngine.InputSystem.Keyboard.current.rightBracketKey.wasPressedThisFrame)
#else
if (Input.GetKeyDown(KeyCode.RightBracket))
#endif
{
CaptureCameraRenderTarget();
}

#if ENABLE_INPUT_SYSTEM
if (UnityEngine.InputSystem.Keyboard.current.leftBracketKey.wasPressedThisFrame)
#else
if (Input.GetKeyDown(KeyCode.LeftBracket))
#endif
{
ScreenCaptureSimple();
}
Expand All @@ -42,6 +55,7 @@ public void CaptureCameraRenderTarget()
public void ScreenCaptureSimple()
{
ScreenCapture.CaptureScreenshot(FilePath);
Debug.Log($"[{GetType().Name}] Simple screenshot saved at <b>{FilePath}</b>");
}

private IEnumerator c_CapctureCameraRenderTarget()
Expand Down Expand Up @@ -100,6 +114,7 @@ private IEnumerator c_CapctureCameraRenderTarget()
bytes = ScreenshotTexture.EncodeToPNG();

File.WriteAllBytes(FilePath, bytes);
Debug.Log($"[{GetType().Name}] Camera texture saved at <b>{FilePath}</b>");
}
}
}

0 comments on commit 302c52c

Please sign in to comment.