Using "ouside" functions inside Unity?


Is it possible to use functions usually used in “normal” C#, inside Unity? There are a lot of good functions outside of Unity that I would like to use in my projects. Outside Unity, C# is a little bit different, but can I still use those functions? Is it just to add “Using System;” and “namespace ProjectName” in the script to make it work? All answers are appreciated.

Yes normal C# works fine. If you import System there are a couple of conflicts with UnityEngine including Object and Random - but you just need to disambiguate them with a using directive or by typing the fully qualified name. You cannot put you MonoBehaviour derivatives in a namespace in version 3.x of Unity - starting with 4 that restriction will be lifted. Other classes can be in namespaces.

You can also add a compiled .Net dll to your project’s assets folder, and Unity will automatically add it to the build settings for the scripts, allowing you to use whatever’s defined in there. So if something’s not there, you can add its dll to your project (such as the VB .Net libraries).