Home > other >  Is there any way to make F# discriminated unions work in Unity?
Is there any way to make F# discriminated unions work in Unity?

Time:09-27

I am experimenting with F# in Unity. I use compiled F# library and FSharp.Core.dll copied to Assets in Unity. Simple scripts work but when I add discriminated union type like

type A = 
    | AInt of int 
    | AString of string

then I get this error in Unity: "Unable to load attribute info on method fs.A:.ctor (). Are you missing a reference?". What can be wrong and is there a way to make it work?

CodePudding user response:

Ensure you are using F# 4.1 - 4.8 in order to be compatible with Unity. F# 5 and 6 are incompatible in exactly the same way as a C# project targeting beyond .NET Standard 2.1.

Tell me more

  • Related