Namespaces and class library

Hey, I’l programmed in .NET and unity for quite some time now and it kinda just hit me that unity rarely if not never uses namespaces. I notices that class libraries are used for firstpass, editor, and VSCSharp but could I if i wanted add additional class libraries and namespaces and access them normally (as I would in regular .NET) and would this also compile to lets say webplayer, mac, linux etc. if I did this?

The main reason i wanna do this is to split parts of my game up in eg. input system, spell systems, and so on since I feel the project is getting a little big.

Also how would I do it so i have access to the scripts from unity if it is possible?

Thanks a lot :slight_smile:

  • Jackie

Unity doesn’t respect the namespace of anything that derives from MonoBehavior but you’re free to put any other classes into your own namespaces. I do.

What a shame… How about un- and managed Class libraries?

Not sure I understand. What about them?

in other words can I add class libraries, and other C# references to unity or C# solutions and use them with unity? lets say I have a class library to do some calculations for AI behaviors that I wrote in .net for instance, or even just in unity, would I then be able to use them with unity? or split scripts whitin unity up in multiple solutions?

That’s wrong! Since Unity 4, you can place any class in a namespace!

Thanks for pointing this out :slight_smile: would still like to know if i can use other .net class libraries in unity :slight_smile:

Seriously? That’s great news! Time to go do some cleanup on my code base. :slight_smile:

Do you mean by using other .net libraries that you want to use .net dll files? If yes, then the answer is absolutely yes. A lot of people compile their own managed dll’s to use them in Unity, including myself. It is important that the compiler is compatible with the one from Unity.

Aaah great, can I also inside unity add scripts to a managed library, or create libraries in unity? I know I can do it within mono and/or VS :slight_smile:

That is not supported by default. But you could write a script to compile your own dll as editor extension.

What a shame… Oh well thanks a lot for helping every one :slight_smile: