I have a specific camera for taking screenshots and call the screenshot2 function as outlined in the documentation (screenshot2 | Needle Engine).
My question is: when I specify the camera in the screenshot2 function, it doesn’t capture the assigned camera but instead captures the main camera. Why does this happen?
Any help would be appreciated ![]()
Here is the full script:
export class ScreenShot extends Behaviour {
private width: number = 1024;
private height: number = 1024;
@serializable(Camera)
screenShotCam?: Camera;
public TakeScreenshot(value: boolean) {
const screenshotData = screenshot2({
camera: this.screenShotCam,
width: this.width,
height: this.height,
mimeType: "image/png",
transparent: false,
});
if (screenshotData) {
saveImage(screenshotData, "Boardshot.png");
console.log("Captured!");
} else {
console.log("Failed to capture screenshot");
}
}
}
Unity version 2022.3.18
Needle ver. 3.47.2
