Up to date
This page is up to date for Godot 4.0
.
If you still find outdated information, please open an issue.
Cross-language scriptingΒΆ
Godot allows you to mix and match scripting languages to suit your needs. This means a single project can define nodes in both C# and GDScript. This page will go through the possible interactions between two nodes written in different languages.
The following two scripts will be used as references throughout this page.
extends Node
var my_field: String = "foo"
func print_node_name(node: Node) -> void:
print(node.get_name())
func print_array(arr: Array) -> void:
for element in arr:
print(element)
func print_n_times(msg: String, n: int) -> void:
for i in range(n):
print(msg)
using Godot;
public partial class MyCSharpNode : Node
{
public string myField = "bar";
public void PrintNodeName(Node node)
{
GD.Print(node.Name);
}
public void PrintArray(string[] arr)
{
foreach (string element in arr)
{
GD.Print(element);
}
}
public void PrintNTimes(string msg, int n)
{
for (