godotengine / godot

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

C# EditorPlugin relative paths #49539

Open thinkrapido opened 3 years ago

thinkrapido commented 3 years ago

Godot version

3.3.2.stable.mono.official

System information

Windows 10, GLES 3

Issue description

        var script = GD.Load<Script>("MyButton.cs");
        var texture = GD.Load<Texture>("bubble.png");
        AddCustomType("MyButton", "Button", script, texture);

searches from Project root not from addons//....

It is not possible to work that way and create a plugin.

You also can't enable the EditorPlugin before you have saved and then build the whole project.

Steps to reproduce

Follow https://docs.godotengine.org/en/stable/tutorials/plugins/editor/making_plugins.html for c# editor plugin.

It won't work until you didn't build the project first time.

Second, this issue, relative paths to MyButton can't be accessed in this addon folder because var script = GD.Load<Script>("MyButton.cs"); searches from project root.

You also need to rebuild the project and disable-enable the plugin all over again to fetch the latest changes

Minimal reproduction project

No response

Calinou commented 3 years ago

cc @neikeq

It is not possible to work that way and create a plugin.

It's less convenient to use absolute paths, but I wouldn't say it's impossible either.

You also need to rebuild the project and disable-enable the plugin all over again to fetch the latest changes

This is an expected limitation of C# editor plugins right now. It's recommended to write editor plugins in GDScript due to this. You can still use C# for the rest of your project.

nongvantinh commented 3 years ago

C# and C++, Java, C, Fortran,.... All compiled language needs to rebuild every time you make changes, Unity don't have to do this because every time its editor loss focus and active again Unity will start to rebuild the project and get the newest changes for you.

preload in GDScript and GD. Loadin C# always look in root project since the first time.

disable-enable the plugin all over again to fetch the latest changes

This happens with GDScript as well.