+3 votes

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


asked Dec 5, 2017 in Engine by Antonb (61 points)

1 Answer

+3 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#).

answered Dec 5, 2017 by Zylann (27,008 points)
selected Dec 6, 2017 by Antonb

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 How to use this Q&A? before posting your first questions.