godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.81k stars 20.14k forks source link

Assets should be imported before running plugins and tool scripts #36713

Open aaronfranke opened 4 years ago

aaronfranke commented 4 years ago

Godot version: 3.2 stable

OS/device including version: Ubuntu, but likely applies elsewhere.

Issue description:

If I delete .import and load the 2.5D demo projects, I get this error:

Unable to load addon script from path: 'res://addons/node25d/node25d_plugin.gd' There seems to be an error in the code, please check the syntax.

However, if I then restart Godot, it works fine.

I think the root of the problem is that the assets are currently imported after (or at the same time as) the plugins are ran. This causes the scripts to fail the first time, so it's really annoying.

To fix this issue, Godot should import all assets before attempting to run plugins or other scripts.

EDIT: Actually, it's not so simple. Some scripts we want to run before importing assets. For example, scripts that extend the GLTF importer need to be run before GLTF files are imported. So we need some kind of dependency system that determines which assets a script needs to be imported before running. Or maybe as a quick fix we can force simple PNG/JPEG/etc files to import before scripts, and have more complex models wait to import? I'm not sure, it's a tricky situation.

akien-mga commented 2 years ago

Reopening as #52344 was reverted due to regressions.

nathanfranke commented 2 years ago

Using load instead of preload in plugin.gd seems to work for me.