I have created an export variable in my C# script, but it does not want to show up in godot. I've tried restarting godot, building the game, running the game, deleting the config folder, gecloning. Other teammembers also seem to have problems getting the export variable to show up in godot.

You can access the whole code here. (/src/microbe_stage/editor/MicrobeEditorCheatMenu.tscn) I've also tried the code without the extra layer of inheritance, but it still doesn't work.

My script:

using Godot;

public class MicrobeEditorCheatMenu : CheatMenu
{
    [Export]
    public NodePath InfiniteMPPath;

    private CheckBox infiniteMP;

    public MicrobeEditorCheatMenu()
    {
        infiniteMP = GetNode<CheckBox>(InfiniteMPPath);
    }

    // More code...
}
using Godot;

public abstract class CheatMenu : Popup
{
    // More code...
}

Welcome to the forums @JaFu0815!

I’m not sure why the exported variables are not working, but I have found in my C# work with Godot that using the GetPropertyList, Set and Get functions work even with inheritance. It does take quite a bit more code though compared to just using [Export] though.

I mean, it works everywhere else. If this really is a godot bug, I'll open a github issue about it.

PS.: I've also tried having a Node as the scene root and letting MicrobeEditorCheatMenu inherit directly from Node

I've fixed it. My mistake was adding the GetNode calls into the constructor. The godot editor seems to use that somehow and that internally seemed to throw exceptions, because the Paths were null at that point.

Awesome! I'm glad you were able to find a solution :smile: Thanks for posting it here so if anyone else has the same issue, hopefully they can read through this thread and maybe solve their issue as well. (Apologizes for not replying sooner! I had read the replies but didn't have the time to reply when I read them, and then I forgot.)

2 years later