godotengine / godot

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

C# Exported Array<Node> is null #97190

Open LasseSchnepel opened 1 month ago

LasseSchnepel commented 1 month ago

Tested versions

4.3 stable

System information

Godot v4.3.stable.mono - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1070 Ti (NVIDIA; 31.0.15.3623) - AMD Ryzen 7 2700X Eight-Core Processor (16 Threads)

Issue description

I have a larger project, that uses C# for all the scripts. Everything works fine when I start the game from the editor. When I export it, I get several errors, that I was able to trace back to that an exported variable is null, instead of being set to the value that is stored in the scene. This applies to exported variables, that are made of a Godot.Collections.Array, where can be Node or any other Script that inherits from Node. If I replace the Array with Node[], the export is working fine.

Steps to reproduce

Unfortunately, I was not able to create a MRP, as the issue did not persist in a minimal project. So unfortunately, I do not know how to reproduce, but I can share the code with one or two people who want to investigate the issue.

Minimal reproduction project (MRP)

I was not able to create a MRP and don't want to publically share my project, but I can share the code with one or two persons who want to investigate the issue.

AThousandShips commented 1 month ago

but I can share the code with one or two persons who want to investigate the issue.

This will not work, if you are unable to reproduce this in a new project an MRP is going to be necessary, so please try to create one, or this won't be possible to test

LasseSchnepel commented 1 month ago

Hi @AThousandShips, Yes, I understand that. While I was not able to reproduce a MRP from scratch, I now tried to strip everything from my project and I think I have a quiet minimal example now.

While stripping it down and, I realized that there are multiple scenarios, which all behave different:

So, I would sum it up as: C# Properties (maybe only Array) are being removed from the .tscn file if the scene is opened before the project is build for the first time.

I hope this helps, please find the MRP attached: mrp.zip

AThousandShips commented 1 month ago

That should hopefully help! Thank you! Can't test C# projects myself at the moment but I'm sure someone will take a look