• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by LeetRooster · Jul 31, 2013 at 03:33 AM · c#monodevelopvisualstudioexternal-tools

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?

Comment
Aggressor
ilya_ca

People who like this

2 Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Benproductions1 · Jul 31, 2013 at 04:05 AM 0
Share

For the second alf of your question:

http://lmgtfy.com?q=Unity+and+VS

avatar image ATMEthan · Jul 31, 2013 at 02:10 PM 0
Share

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!

avatar image ilya_ca · Jan 30, 2015 at 01:02 PM 0
Share

@ATMEthan the PostSharp4Unity doesn't relate to Unity3D engine. It relates to a .NET IoC framework.

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

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.

Comment
Bunny83
El Maxo
Aggressor
ilya_ca

People who like this

4 Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Xtro · Jun 15, 2017 at 02:16 PM 1
Share

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 :)

avatar image TheHeftyCoder · Nov 19, 2018 at 04:40 AM 0
Share

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 Mono Compiler. I see now you have to use UnityEngine.dll inside Visual Studio, alongside THE IMPLEMENTATION 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 - Mono Compilers. How does that even work correctly, or would errors happen when using anything more than Debug.Log()?

avatar image Xtro TheHeftyCoder · Nov 21, 2018 at 04:47 PM 0
Share

@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. Maybe hundred thousands of developers are compiling their library or game code into DLLs instead 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.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Want to use Unity and C# for top-down game! Wich IDE? 0 Answers

Can't save C# scripts? 0 Answers

Distribute terrain in zones 3 Answers

Sync with visual studio 2010 error 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges