<aside> 📄 This script is intended for use with the “ScreenshotCapture” script. Use these scripts to take hi-res images of your project during play in the Unity editor. Add the script to an empty GameObject in the scene. Attach the script to the ScreenshotCapture GameObject. Press play and right click with the mouse to take images.

</aside>

using UnityEngine;

public class RightClickCapture : MonoBehaviour
{
	public ScreenshotCapture screenshotCapture;
	
	void Start()
	{
    // Ensure the screenshotCapture reference is set
    if (screenshotCapture == null)
    {
        screenshotCapture = GetComponent<ScreenshotCapture>();
        if (screenshotCapture == null)
        {
            UnityEngine.Debug.LogError("ScreenshotCapture component not found!");
            return;
        }
    }
	}

	void Update()
	{
    // Check for right mouse button click
    if (Input.GetMouseButtonDown(1)) // 1 is the right mouse button index
    {
        // Call the Capture method
        screenshotCapture.Capture();
    }
	}

}