10

How can I use Clojure-CLR on Unity3d?

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
damon-kwok
  • 125
  • 7
  • possible duplicate of [How mature is clojure-clr? Can I use it with Mono?](http://stackoverflow.com/questions/6073848/how-mature-is-clojure-clr-can-i-use-it-with-mono) – Sylwester Jul 30 '13 at 08:13
  • Could you consider expanding this question to ask for something a little more specific? – Arthur Ulfeldt Jul 30 '13 at 08:26

2 Answers2

10

The complex answer is "maybe you can", the pragmatic answer is "no, you can't".

Sylwester suggested this is a duplicate of using it with Mono, which isn't really true, because Unity uses its own fork of Mono(one that's very old...2.6?), so something that's compatible with Mono won't necessarily have compatibility with Unity.

ClojureCLR requires the DLR(though they've been moving away from it), which means it's incompatible with Unity, since the DLR requires Mono 2.8+.

That said it's possible to add the DLR as a dependency, and to compile ClojureCLR to .dlls and access it from Unity, this is what I did, however my experience was that I could get a lot of my code to run fine in the development environment, but when I'd build the game, everything would break, it'd just ignore the Clojure stuff.

If Unity moves to a higher version of Mono, or ClojureCLR gets rid of dependence on the DLR, I don't see any reason Unity couldn't support it, and I actively look forward to it. But for the moment, it's not practical.

If a work-around exists(and it probably does), I never managed to figure it out.

VFe
  • 223
  • 2
  • 8
  • 1
    Good to note that ClojureCLR does plan to get rid of the DLR: http://clojureclr.blogspot.com/2012/06/clojureclr-14-released-with-code-gen.html - there is a nodlr branch in the clojure-clr github repo, but it's not in master yet. That being said, it's very easy to drop the 3 DLR dlls into the Assets folder. No need to recompile ClojureCLR or anything. – gregschlom Jun 18 '14 at 22:48
3

People in the Clojure community have gotten something working.

From @swannodette "Looks like @ra and @timsgardner got Clojure running inside Unity last night"

http://f.cl.ly/items/2T2d340o0k0W2d44212G/clj2.gif

adamhill
  • 296
  • 2
  • 10
  • 1
    Here's the link to their githup repo: https://github.com/nasser/clojure-unity - I've tried the code and found it relatively easy to call Clojure functions from a C# file in Unity, but it was just a quick test, not a large-scale experiment. – gregschlom Jun 18 '14 at 22:43
  • 1
    New repo location, https://github.com/arcadia-unity/Arcadia. GitHub is redirecting right now but may stop at some point in the future. – James McMahon Jul 20 '15 at 12:56