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.
+3 votes

I register class name with class_name keyword

extends Object
class_name MyClass

And than inside other script I instantiate it like that

var obj =

Is it differs from that methods?

var MyClass = preload("")
var obj =


var MyClass = load("")
var obj =

If I instantiate object using registered class_name, will be script loaded during runtime or during compilation time?

in Engine by (275 points)

1 Answer

+2 votes

you can read about it here:

  • Named scripts are registered globaly on startup.
  • Preloaded scripts are loaded into a var or const in a class on compile time. They are not globaly accessable.
  • Loaded scripts are loaded on runtime into a class variable. They are not globaly accessable.
by (4,088 points)

So, will it be loaded before runtime?

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.