• Stars
    star
    166
  • Rank 227,748 (Top 5 %)
  • Language
  • Created over 10 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Instructions for using F# with Unity

How to use F# libraries with Unity

Note: this has only been tested out with Xamarin Studio on Mac OS X

  1. Create a Unity Project
  2. Create a F# project (lib) and put it in the root of the Unity project
  3. In the Unity 'Assets' folder, create a folder called 'Frameworks' and add the FSharp.Core.dll to it
  4. Open the preferences for the F# project and change the 'Target Framework' to 'Mono / .NET 3.5'
  5. Remove all References in the project, except FSharp.Core (2.3.0), System and System.Core
  6. Add the unity mscorlib.dll to somewhere in the F# project folder, and then to the project References
  7. Make a custom build command (working dir: ${TargetDir}) that copies the resulting dll to the Unity 'Frameworks' folder
    cp MyFsharpLib.dll ../../../../Assets/Frameworks/
  • You can access namespaces/classes from C# components just like you'd expect

How to write Unity components in F#

  • Copy UnityEngine.dll to the F# project and add it as a reference
  • The component will show up under the DLL in Unity's Project view, click the little arrow to fold it out (or just add it to a game object using the Add Component menu)
  • Import the Unity namespace
    open UnityEngine
  • Inherit from MonoBehaviour, as usual
    type SimpleComponent() =
    inherit MonoBehaviour()
        member this.stuff = 42
  • To show properties in the inspector, make them mutable and serializable
    [<SerializeField>]
    let mutable changeSpeed = 2.0f
  • Override member functions
    member this.Start () = 
        this.transform.Translate(1.0f, -1.0f, 2.0f)
  • Mutate members
    this.renderer.material.color <- Color.red

Hey, if you like this repo maybe you'd be interested in the language I'm working on. It's a functional language aimed at game development. Read more about it here: https://github.com/eriksvedang/Carp

More Repositories

1

Sprak

Easy-to-use programming language made for the game Else Heart.Break()
C#
65
star
2

GameWorld2

C#
53
star
3

SecretArcade

The wiki for the Secret Arcade.
41
star
4

Grimm

Game story scripting language
C#
26
star
5

Hotrod

A library for hot reloading of C functions
C
22
star
6

othello

A simple Othello game for Light Table
JavaScript
16
star
7

.emacs.d

Emacs Lisp
13
star
8

Relay

Database written in C# to be used for easy saving and loading in games
C#
11
star
9

carp-ncurses

C
6
star
10

TingTing

Entity management framework that integrates with the Relay library
C#
6
star
11

unity-lisp

Lisp to Unity Script converter
Clojure
5
star
12

GameTypes

Utility library used by several of our C# projects
C#
5
star
13

SplicersWeb

The website for Splicers – the open source collectible card game!
Haskell
5
star
14

DependencyDay

My entry for the Lisp Game Jam, spring 2018
5
star
15

Pathfinding

A-star library
C#
4
star
16

data-to-html

Convert clojure data to html
Clojure
4
star
17

AStarInC

A proof of concept implementation of the A* algorithm, using C.
C
3
star
18

Haskolog

Simple prolog implementation made together with Víctor López
Haskell
2
star
19

Rogue

2
star
20

UnitySnippets

Reusable code for the Unity game engine
C#
2
star
21

Arduino

Arduino sketches and stuff
Arduino
2
star
22

mosh-pit

Lisp Game Jam, spring 2019
C
2
star
23

Trams

Mini projects and other random programming stuff
Ruby
2
star
24

gomoku

Clojure
2
star
25

haskell-markov

Haskell
2
star
26

NoMoreMoneyMonteCarlo

Haskell
2
star
27

Motor

Haskell
2
star
28

OpenGlBookInRust

Rust
1
star
29

Pow

C#
1
star
30

whale

Ruby
1
star
31

Mini

Very minimal OpenGL (with GLFW and GLEW) application.
C
1
star
32

GuiImprove

C#
1
star
33

Bazaar

HTML
1
star
34

lambdacalc

An implementation of λ-calculus based on the one found in 'Understanding Computation'
Clojure
1
star
35

aseriesofinterestingchoices

The web page of my board game "A Series of Interesting Choices"
HTML
1
star
36

sleazy

Haskell
1
star
37

Matematik1

Some code related to the math course I'm taking...
Haskell
1
star
38

SharpLisp

C#
1
star
39

Pilsner

My own Lisp, finally!
C
1
star
40

Pearls

Haskell
1
star
41

recursion-schemes

Haskell
1
star
42

Opus

I followed a tutorial on OpenGL in Haskell
Haskell
1
star
43

GameLecture

A lecture about making small games in Haskell, presented at Got.λ Aug 28, 2014
Haskell
1
star
44

Moose

Playing with modern OpenGL in Haskell.
Haskell
1
star
45

FlappyLambda

Just trying to write a game in Haskell
Haskell
1
star
46

trede

Generating little 3D meshes with Quil.
Clojure
1
star
47

polynim

Polygon animations in Quil
Clojure
1
star