How to get all screens of the computer ?

Hi all,

I got a problem, I need to know how many monitors the computer has in my unity projet, but I understand Unity doesn’t like System.Windows.Forms. I wanted to use the Screen.AllScreens function because it’s really what I want.

Is there a way to do the same thing from Screen.AllScreens in Unity 5 ? I tried to create a DLL which using Screen.AllScreens and I import the dll in my project

public class AllScreens
{
        public System.Windows.Forms.Screen[] screens;

        public int GetAllScreens()
        {
            screens = System.Windows.Forms.Screen.AllScreens;
            return screens.Length;
        }
}

but apparently doesn’t work in my unity projet. My object is null all the time when I initialize it when I use System.Windows.Forms but the system works when I use my DLL for whatever else like :

public int AddValue(int a)
{
       return a + a;
}

Anyone have idea for do that ?

Thanks :slight_smile:

If you need System.Windows.Forms.Screen this could be helpfull: http://www.pencilsquaregames.com/2013/06/how-to-use-the-system-windows-forms-dll-inside-unity-windows-only/

Great it works ! Thank you :slight_smile: