mcDesktopCapture icon indicating copy to clipboard operation
mcDesktopCapture copied to clipboard

Unity Asset to capture the macOS desktop as Texture2D

mcDesktopCapture

Platform Unity Xode

Unity native plugin to capture the macOS desktop as Texture2D

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 Recording and add Unity.app.
    (And Unity Hub.app if you use)

Usage

mcDesktopCapture mcDesktopCapture2
Unity Unity 2021.X
Unity 2022.X
Unity 2022.2+ (Apple Silicon)
Unity 2021.X
Unity 2022.X
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

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();