McDesktopCapture
Unity Asset to capture the macOS desktop as Texture2D
Install / Use
/learn @fuziki/McDesktopCaptureREADME
mcDesktopCapture
Unity native plugin to capture the macOS desktop as Texture2D
<video src="https://user-images.githubusercontent.com/33706353/180478830-64fae2ab-321e-4d88-9eb6-b6dfc121da31.mp4"></video>
Installation
- Download mcDesktopCapture.unitypakcage from Releases and install it in your project.
- To allow monitoring of keyboard input in the background, you need to add Unity to Privacy Settings.
- Open
System Preferences>Security & Privacy>Privacy>Screen Recordingand addUnity.app.
(AndUnity Hub.appif you use)
Usage
| | mcDesktopCapture | mcDesktopCapture2 | | :--- | :--- | :--- | | Unity | Unity 2021.X<br>Unity 2022.X<br>Unity 2022.2+ (Apple Silicon) | Unity 2021.X<br>Unity 2022.X<br>Unity 2022.2+ (Apple Silicon) | | Platform | macOS 12+ (Apple Silicon and Intel) | macOS 12.3+ (Apple Silicon and Intel) | | Technology | Quartz Display Services | ScreenCaptureKit | | Capturing | Entire Display | Each windows |
mcDesktopCapture
- Support macOS 12+
- Based on Quartz Display Services
- This function only supports capturing the entire display.
Start capture
var list = DesktopCapture.DisplayList;
DesktopCapture.StartCapture(list[0].id);
Set Texture
var texture = DesktopCapture.GetTexture2D();
if (texture == null) return;
Renderer m_Renderer = GetComponent<Renderer>();
m_Renderer.material.SetTexture("_MainTex", texture);
Stop capture
DesktopCapture.StopCapture();
mcDesktopCapture2
- Support macOS 12.3+
- Based on ScreenCaptureKit
- This feature is able to capture each window.
Start capture
DesktopCapture2.Init();
var list = DesktopCapture2.WindowList;
var window = list[0];
DesktopCapture2.StartCaptureWithWindowID(window.windowID, window.frame.width, window.frame.height, true);
Set Texture
var texture = DesktopCapture2.GetTexture2D();
if (texture == null) return;
Renderer m_Renderer = GetComponent<Renderer>();
m_Renderer.material.SetTexture("_MainTex", texture);
Stop capture
DesktopCapture2.StopCapture();
DesktopCapture2.Destroy();
