So I have been playing around with .Net dlls inside unity and wanted to check some functions inside the System.Windows.Forms.dll in order to access the primary monitor screen size but found out that Unity’s .Net embebed runtime doesnt include the System.Windows.Forms.dll so here is a way to include it in your project.
Go and grab System.Windows.Forms.dll and System.Deployment.dll from “C:/Windows/Microsoft.NET/Framework/v2.0.50727/” and copy those dlls to your project at “Assets/Plugins/” , after that, you are almost done, you just need to go to “Edit -> Project Settings -> Player” in Unity and go to the “Other Settings” tab and under the Optimization label on the “API Compatibility Level” just select “.Net 2.0″ instead of “.Net 2.0 Subset”.
Then you are good to go and use the dll functions, just create a small script like this to check it out:
1 2 3 4 5 6 7 8 |
using UnityEngine; using System.Windows.Forms; public class Example : MonoBehaviour { void OnGUI() { GUILayout.Label(Screen.PrimaryScreen.Bounds.ToString()); } } |
I havent tested that much if this will work on other platforms will give you warnings or problems but seemed to work for me, if you have any problems making it work let me know.