This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hi!

I've been doing this for quite a while now, simply because it makes my code so much cleaner and easy to read, but I'm not quite sure if this is a bad practice. I started doing this because I saw some code written in gdscript which used preload(), which isn't a thing in C#.

Does using ResourceLoader.Load() at the top of the script to declare a PackedScene variable affect in a negative way the performance of my game?

Here is an example code in C#:
PackedScene chicken = (PackedScene)ResourceLoader.Load("res://Assets/Scenes/Animals/Chicken.tscn");

Thanks in advance!

Godot version 3.2.3
in Engine by (149 points)

1 Answer

0 votes
Best answer

Hi!

No, unless you do it once at when the game starts or scene switches.

ResourceLoader.Load is an I/O operation, which loads content from disk. So just don't put it into the Process(float delta) method.

by (1,081 points)
selected by
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.