- Home /
Can you use PostSharp in Unity?
Has anyone done this successfully?
PostSharp is downloadable as a visual studio plugin a vsix file. Their requirements are:
Microsoft Visual Studio 2010 or 2012, except Express editions.
Windows XP with SP3 or later.
NuGet Package Manager 2.2 or later.
If you develop your unity project in visual studio will this work? Will unity know how to build/run your code? Can you get unity to run a dll that VS builds?.
Do you lose debugging support? Which I believe is only available through MonoDevelop?
For the second alf of your question:
http://lmgtfy.com?q=Unity+and+VS
I only know for sure that you can use Visual Studio. That would lead me to believe that you would be able to use the plugins. I only scanned this webpage but it looks doable http://code.google.com/p/postsharp-user-plugins/wiki/PostSharp4Unity . If you get it working post your answer here to others can know as well!
@AT$$anonymous$$Ethan the PostSharp4Unity doesn't relate to Unity3D engine. It relates to a .NET IoC framework.
Answer by Xtro · Jul 31, 2013 at 03:16 PM
By adding the required assemblies(C# DLLs) to your project structure in Unity, you can use their namespaces(and classes in them) in your unity code.
You should do "using XyzNamespace;" but I'm sure you are aware of that.
Btw, Assemblies should be compiled for .NET2 or 3.5, not later than that.
Interestingly, I didn't know what PostSharp is when I wrote that answer. I just assumed PostSharp dll is just a regular dll.
Now, I know what actually PostSharp is and I love it. I use it in my Unity projects via my manually compiled Visual Studio class libraries (DLLs).
I still wonder if I am the only person who uses PostSharp in Unity. I would like to know if I am not the only one :)
How do you actually do that?
Building a .dll, do you then just drag this file into Unity, or do you need to Add PostSharp via Solution Explorer as well? That didn't work for me, Unity doesn't recognize PostSharp as a reference if I do it that way, resulting in Editor exceptions.
I even dragged the PostSharp.dll file that was build with my custom.dll (after loading a backed up project that was PostSharp free). This time I had both PostSharp and custom utility references as dlls. I could write PostSharp code, even use Unity API with it but nothing worked when I run it, at least in the Editor.
Is there something specific you do?
Edit: Damn that $$anonymous$$ono Compiler. I see now you have to use UnityEngine.dll inside Visual Studio, alongside THE I$$anonymous$$PLE$$anonymous$$ENTATION of PostSharp and then move that .dll inside Unity to use. Really would like to know how Unity treats compiled .dll that comes from non - $$anonymous$$ono Compilers. How does that even work correctly, or would errors happen when using anything more than Debug.Log()?
@TheHeftyCoder I really wanna help you with this but I don't have free time to provide a detailed answer right now. I still use PostSharp on my DLLs which are imported to my Unity projects.
The short answer for now: Unity can import and run non-mono compiled DLLs perfectly. You can compile a DLL in Visual Studio and Unity will not even notice the difference. $$anonymous$$aybe hundred thousands of developers are compiling their library or game code into DLLs ins$$anonymous$$d of writing open scripts as # files in Unity.
Even if you apply automatic PostSharp modifications to your DLL, it's still a DLL so Unity can import and run them correctly.
I'll keep your question in my email inbox and I'll try to give you some detailed info when I have time.