A Godot Engine plugin to simplify using F# through the C# Mono language.
- Generating an F# project file and adding it to your Godot C# project/solution
- via Tools menu shortcut.
- Generating an F# script from a selected C# script.
- via Tools menu shortcut.
- Automatically Generating F# scripts from all C# scripts.
- via configuration in ProjectSettings under Mono > F# Tools
- Note: All F# classes must have the same name as their C# counterpart with an "Fs" on the end, e.g.
MyClass.cs -> MyClassFs.fs
.
- Download the .zip from GitHub or clone the repository.
- Copy/paste the
addons
directory into your project or create a symlink between theaddons/godot-fsharp-tools
directory and a similar one in your project. - Open the ProjectSettings, go to the Plugins tab, find "Godot F# Tools" and switch it from "Inactive" to "Active" on the right-hand side.
- Make sure that you've installed the Mono version of Godot and the dotnet command line tool of which this plugin makes heavy use.
These instructions assume that you...
- Have already created a C# project/solution by first creating at least one C# script in your Godot project.
- Have installed and activated the plugin.
- Go to
Project > Tools > Setup F# project...
. A dialog will open. - Fill in the necessary fields. Unnecessary fields will tell you what default value they become if left empty.
- Once confirmed, the dialog will generate the F# project and connect it to your C# project/solution for you. This may take a short while.
- Go to
Project > Tools > Generate F# script from C# script...
. A dialog will open. - Fill in the necessary fields. Unnecessary fields will tell you what default value they become if left empty.
- The namespace must match that of the F# library project to which you plan to add it.
- Once confirmed, the dialog will generate the F# script and update the C# script to inherit from your F# class and include its namespace.
- You will need to add the new F# script file to your F# library project manually.*
- Go to
Project > ProjectSettings
. Go to theGeneral
tab. Scroll all the way to the bottom and find theMono > F# Tools
category. - Fill in information for all fields in this section.
- The namespace must match that of the F# library project to which you plan to add it.
- For better organization, we recommend using the F# library project directory for the output directory.
- Create a C# script. The editor will generate a corresponding F# script in the output directory and update the C# script to inherit from your F# class and include its namespace.
- You will need to add the new F# script file to your F# library project manually.*
* The reason you must do this manually is because...
- the
dotnet
tool from Microsoft does not support adding items to projects ("Really? Seriously? Professional stuff here guys"). - Godot's
XmlParser
class only allows you to read XML nodes, but not insert them into an .xml file ("Really? I mean, that could be useful guys..."). - If you want to write your own XML parsing code to inject the file reference into the
<ItemGroup>
tag hierarchy, it would be appreciated.
For the uninformed, you add an existing item to an F# project in the following way:
- Have Visual Studio installed with F# support.
- Open the Godot .sln file in Visual Studio.
- Right click on the F# library project in the Solution Explorer dock.
- Go to
Add > Add Existing Item...
. - Choose the
<classname>Fs.fs
file you generated. Hit "OK".
OR
- Have Visual Studio Code installed with the
Ionide-fsharp
extension. - Open the Godot directory in your workspace. Ionide's F# solution tab should automatically detect and add the F# project.
- In the F# tab on the left, you should see your project's .sln and under it the .csproj / .fsproj directories.
- Right-click the F# project directory. Choose
Add file
. - Within the command pallete line edit, type out the name of the F# source file in that directory you want to add. Hit
Enter
.
The F# source file is now added to the F# project!
If you like the project, please give it a star and consider donating to my Kofi. If you have any problems whatsoever, do not hesitate to open an Issue.