Print the Screen Shot by printer from Unity

Hi there,

I have struggle with my project now, i need to take the print out from my unity scene.

Actually i have a scene which is have some model, i have a button in this screen when i click the button the screen should be take screenshot and it should be print in my printer. This is my function.

For the screen shot we can use Application.ScreenShot("Image.png")

But i dont know how to print this image by the printer.
Please help me to do this.

Thanks.

This is my first reply, but I can not help you , I think you should be search the printer how to work and is there a interface work in the unity.

If you want to render a captured screenshot in the game, have you tried ReadPixels?

but i need to print the screen by printer

best i could find… and don’t you mean

Application.CaptureScreenshot("filename")

?

although there is this:

which is generic c# i think… no idea if it’ll work in unity though.

I am using the unity 3.5.7 (no pro) when check below line i can’t get.

using System.Drawing.Printing;

is this drawing function available in unity ?

System.Drawing is not available in Unity.

I see two possible solutions:

  1. Use Application.CaptureScreenshot to make and save the screenshots and make a satellite application (a service maybe) that will watch the folder where the images appear and print them automatically.

  2. It is still possible to use unmanaged code and call WinAPI functions in Unity, even in the free version. But it’s the hardest way, I guess.

If you don’t have Pro, you’re not going to really be able to ensure this works. I think a valid question is “why are you trying to do this anyway?” I mean, the last thing I want is a game wasting my ink/toner by printing more than zero screenshots.

Actually i need to print out the each and every object functions, when user interact with my scene they might have get more information, so they need to print out that information so that i need one button on my scene when the user click the button the corresponding scene(display) should print by printer.
This is the task assigned by my project manager.

and another doubt i have i got this line from some where in net “using System.Drawing.Printing”
i have tried in my monodevelop but it didn’t come, may be this will come only unity 4 versions?

if i will install pro can i get this?

No.

Try this:

System.Diagnostics.Process.Start("mspaint.exe", "/pt d:\\screenshots\\sample.jpg");

so we can’t do direct print ?

i have wrote the below line

if(GUI.Button(Rect(10,10,100,30), "print"))
{
System.Diagnostics.Process.Start("mspaint.exe","D:\\Unity\\Unity Projects\\JPEG Encoding\\Assets\\unity"+count+".png");
}

When i press the “E” key the screen shot will save to this path “D:\Unity\Unity Projects\JPEG Encoding\Assets\unity”+count+“.png”
count will increase the each time you press the E button like this:
unity0.png, unity1.png, etc.,
Now i press the print button the the last image will be open in paint but its always open the first image , i dont know whats the problem in this.
Please help me to solve this.

// Update is called once per frame
	void Update () {
		
		if(Input.GetKeyDown(KeyCode.E))
		{
			 Application.CaptureScreenshot("Screenshot"+count+".png");
			count++;
		}
	
	}
	void OnGUI()
	{
		if(GUI.Button(new Rect(10,10,100,30), "print"))
		{
			System.Diagnostics.Process.Start("mspaint.exe","Screenshot"+count+".png");
		}
	}

but its not run properly after i took built.

I have tried to import this line in my scripting, but my monodevelop does not support this.

using.System.Drawing;
using.System.Drawing.Printing;

I am using the unity 3.5.7, i dont know what the problem is this.
can we use this drawing property in unity 3d?

Thanks.

You just can’t use System.Drawing[.xxx]. It heavily uses Windows GDI API and is not supported in Unity.

string filename = @"d:\screenshot.png";
			
if (File.Exists(filename))
{
	File.Delete(filename);
}

Application.CaptureScreenshot(filename);
System.Diagnostics.Process.Start("mspaint.exe", "/pt " + filename);

if i use any DLL and integrate with the system dll then can we call the printer through the scripting?

I didn’t get the idea.