I am having a C# code in which there are few packages.I want to add those packages in my Unity script. The packages are:
using System.Windows.Shapes;
using System.Windows.Media;
using System.Windows.Controls;
using System.Windows;
I tried adding them but I am getting the error:
The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
HOw to make these packages working in my script?
1 Answer
1
You have hit a constraint of Mono (what Unity compiles your scripts into).
Because Mono can run on unix/mac etc some classes are not relevant to the mono namespace. I.e. windows specific methods and classes.
You can visit this unity documentation page to see if the classes you are trying to use exist in the mono subset: http://unity3d.com/support/documentation/ScriptReference/MonoCompatibility.html
Please note: that if you are using Visual Studio as your editor it may appear to compile fine there, but fail in Unity. This is because VS is using the .net compiler that does know about the System.Windows classes, unity compiles in Mono, which doesn’t.
Getting your code working: Unfortunately if you want to get your code to work in Unity, you will have to refactor it so it only uses classes/namespaces that Mono supports. This may mean dropping functionality or working out how to implement it via mono classes.