Function not recognized by game when calling c# script from a gdscript

Godot Version

4.3 (.net)

Question

Hi, a team member of mine has written a sqlite database for our project, and it’s wrapped in several c# scripts to manage the database. When detached from the godot project, the database is fine; however, after going through the process to implement the system into the game, including all the nuGet, DLL, and other setup we can’t call the C# functions in game.

He’s trying to have one of our singletons (gobal_data.gd) call the “setup()” function from gamedao.cs.

Here’s the line on the singleton

func _ready() → void:
GameDao.Setup();

Here’s the setup function in question (I’m personally afk and formatting this message correctly on a mobile browser is being weird, sorry for not blocking it):

public async Task Setup(bool drop = false, CancellationToken cancelToken = default)
{
var exec = new SqlExec(_connString, >(drop) ? _buildTables : _dropTables + _buildTables);

	>	return await >exec.ExecNQSPAsync(cancelToken);
	}

My team member has tried different variations of this, like passing null into the function, instantiating gamedao.cs, and more but to no avail. my team member has access to this account that I’m positing from, and in any replies we will indicate whether you are speaking to OP or the one who made the database.

Any help would be much appreciated!

This is sadly a fundamental limitation of how C# works - C# functions and GDScript functions are different things implementation-wise, and GDScript doesn’t know how to call C# functions. There are some things you can do with loading the C# script as a resource and using .call() but it’ll be finnicky, especially with static methods.

OP here, Thank you for letting me know! I personally only have a little c-based language experience, so I just chose to use gdscript for most of my godot work; however, my team member uses c# professionally so he opted for it.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.