How to use C# in Godot

How to use C# in Godot thumbnail

Loading...

This article will be finished soon! You can find sode snippets mentioned in the video below

Setup Godot c# debugging

Visual Studio Code allows to atatch a debugger to running Godot game. This way you can place breakpoints in your code and resolve any problems much faster!
Here is a step by step guide:
  1. In Visual Studio Code go to “Run and Debug” tab
  2. Click “Create a launch.json file” and select any template (for example C#) That will create a new file .vscode/launch.json
  3. Replace all contents of this file with this:
    json
    1{
    2  "version": "0.2.0",
    3  "configurations": [
    4    {
    5      "name": "Play",
    6      "type": "coreclr",
    7      "request": "launch",
    8      "preLaunchTask": "build",
    9    // Replace your "program" path with path to your Godot installation.
    10    // Here you can find some examples (remember to replace [user]!):
    11    // /Users/[user]/Downloads/Godot_mono.app/Contents/MacOS/Godot
    12    // /Applications/Godot_mono.app/Contents/MacOS/Godot
    13    // C:/Users/[user]/Downloads/Godot_v4.1-stable_mono_win64/Godot.exe
    14    // C:/Program Files/Godot/Godot.exe
    15      "program": "[ENTER PATH HERE]",
    16      "args": [],
    17      "cwd": "${workspaceFolder}",
    18      "stopAtEntry": false,
    19    }
    20  ]
    21}
    Please enter your correct path to the Godot Engine in "Program" value. You can find example paths in the comments. Please remove all the comments after finished work.
  4. Create a new file in .vscode folder called tasks.json
  5. Paste this contents in .vscode/tasks.json:
    json
    1{
    2    "version": "2.0.0",
    3    "tasks": [
    4      {
    5        "label": "build",
    6        "command": "dotnet",
    7        "type": "process",
    8        "args": [
    9          "build"
    10        ],
    11        "problemMatcher": "$msCompile",
    12        "presentation": {
    13          "echo": true,
    14          "reveal": "silent",
    15          "focus": false,
    16          "panel": "shared",
    17          "showReuseMessage": true,
    18          "clear": false
    19        }
    20      }
    21    ]
    22  }
  6. Save both files and try out debugging! Open “Run and Debug” tab and press “Play”. That should build and open your Godot game in Debug mode. In this mode all breakpoints will be triggered
divider
discord
Hi! Why don’t you visit my discord?
Copyright © 2024 Teal Fire