Can F# be used with Unity (game engine)?

I had success doing this sometime back by following this Github project: https://github.com/eriksvedang/FSharp-Unity, which I believe is roughly the same as Lars Kokemohr's answer above. I haven't tested it in more recent versions of Unity/Mono however.


I can't help but get the impression that the other answers were written by people who do not really know what they are talking about.

This is what you need to do to use F# in a Unity project:

  1. Create an F# project that compiles into a dll. Have it build into the assets folder of a Unity project.
  2. Add references to UnityEngine.dll and/or UnityEditor.dll. Change the reference properties so the dlls aren't copied to the build folder. Of course you can't create new F# classes from within the Unity editor this way, but you can assign the ones you wrote in F#.

Currently you need to enable the (experimental) support for .NET-version 4.5. Alternatively you can download an older version of the FSharp.Core.dll that supports .NET 3.5. (see here).

I can't guarantee that you won't run into trouble because of compatibility issues with the FSharp.Core.dll, but that's just a guess since I haven't tested it myself.

Tags:

Unity3D