+5 votes

Hi,
how can I access load() and preload() functions in Godot 3 C#? I can't find them in any class.

Thanks.

in Engine by (64 points)

1 Answer

+6 votes
Best answer

There is no load and preload keywords in C#, you have to use the ResourceLoader class instead which does the same thing:

var texture = ResourceLoader.Load("res://icon.png") as Texture;

Also there is no equivalent of preload because that one in particular is specific to GDScript (Godot is able to load resources when the script is loaded, which isn't possible with C#).

by (29,090 points)
selected by

Thanks for the answer. Can you tell me where you got this info? Is there some resource I can take a look at? Because I googled quite a lot before asking and didn't find anything.

I got the info by seeing some examples here https://godotengine.org/article/introducing-csharp-godot, and on Discord by chatting with devs. Infos about C# should be added to official docs but at the moment I don't see them.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.