Hi,
for past few days i am working on tool that will make a screenshot and copy it to Windows Clipboard.
I did read a lot of topics about it.
From what i understand i need to use
System.Drawing.Image tempImage = System.Drawing.Image.FromStream(stream);
System.Windows.Forms.Clipboard.SetImage(tempImage);
I should provide it with stream and it should work just fine.
My problem is about references.
using System.Drawing
and using System.Windows.Forms
doesn’t work. Those ares not seen by unity.
I have compatiblility set for .NET standard 2.0
I found out solution. It is to copy those library into Assets/Plugins folder. I tried to took those from unity directory blablba/mono/2.0/ as well as from .NET directory blablba/ProgramFiles(x86)/Reference Assemblies/etc.
Both didn’t work.
Files from system .NET directory does “Loading assembly failed” error but it seems like System.Windows.Forms.Clipboard is working. Unity shows errors about Image type error CS0234: The type or namespace name 'Image' does not exist in the namespace 'System.Drawing
and error CS7069: Reference to type 'Image' claims it is defined in 'System.Drawing', but it could not be found
Files from unity copied into Assets/Plugins gives me an error about duplication of library and command me to delete one. error CS1703: Multiple assemblies with equivalent identity have been imported
I tried to copy dll-s from higher versions like 4.0 or 4.5-api. Those doesn’t rise Multiple asemblies error but still doesn’t work just like those from Windows .NET directory.
My next steps was to use [DllImport("System.Drawing.dll", CharSet = CharSet.Unicode, SetLastError = true)]
but i am kinda new to this and i am not sure how to get Image type from it and use FromStream method that returns Image object.
Does anyone know how to deal with it? Or at least can point me in the right direction?
Thanks in advance and cheers!