Open Vukbo opened 1 year ago
I can confirm that this is not working for me either, but fairly certain it was working in beta 6.
AudioManager.cs(31,34,31,46): error GD0102: The type of the exported field is not supported: 'QuestoftheWizard_CSharp.AudioManager.nodePathList'
[Export] public List<NodePath> nodePathList = new();
I doubt it was working in beta 6 because as far as I remember we removed support for .NET collections when we moved to .NET 6 (https://github.com/godotengine/godot/pull/64089), which I think was around alpha 16, and we haven't added support back.
For now you should be able to use Godot.Collections.Array
as a replacement.
Keep in mind that converting between .NET collections and Godot collections is possible but can be very expensive because it requires marshaling every element.
List<string> dotnetList = new List<string>() { "a", "b", "c" };
// List to Godot array
Godot.Collections.Array<string> godotArray = new Godot.Collections.Array<string>(dotnetList);
// Godot array to List
godotArray.ToList();
The commit that removed support for .NET collections (3123be2384c14f7dd156b1cc2d53d822002b837a) includes more context:
Removed support for non-Godot collections. Support for them also relied heavily on reflection for marshaling. Support for them will likely be re-introduced in the future, but it will have to rely on source generators instead of reflection.
Will C# Lists be supported in the future again?
C# Lists and other Collections have significantly more features than Godot Arrays, and the conversion always has some code-overhead, that was not necessary in the past, so I would also greatly appreciate if exporting C# Lists became available again.
C# Lists and other Collections have significantly more features than Godot Arrays, and the conversion always has some code-overhead, that was not necessary in the past, so I would also greatly appreciate if exporting C# Lists became available again.
agree
@LeonardoCruzx Please don't bump issues without contributing significant new information. Use the :+1: reaction button on the first post instead.
I'm having a similar issue and trying to come up with some generic solution for this problem. My vision of the fix is not crystal-clear, and I haven't dabbled too deep in godotsharp technicalities, hence I'm not writing a proposal yet, but I'd like to test the waters first and ask for some opinions: https://github.com/godotengine/godot-proposals/discussions/10709
Godot version
v4.0.beta8.mono.official [45cac42c0]
System information
Windows 10 Home, Intel(R) Core(TM) i5-4210H CPU @ 2.90GHz 2.90 GHz,
Issue description
In Godot 3.5 it was possible to Export C# System.Collections.Generic.Lists. When I try doing that in the current version I get the following error:
C:\Users\Bozo\Documents\Data\Game Dev\Godot\super-beat-boy\Nodes\Activables\GravityArea.cs(21,30): The type of the exported field is not supported: 'SuperBeatBoy.GravityArea.listOfStrings'
Would like to Export my lists and use them directly, this was very helpful and streamlined to use. So this seems like a regression to me.
Steps to reproduce
Adding following Snippet to any Code:
[Export] private System.Collections.Generic.List<String> listOfString = new System.Collections.Generic.List<string>();
This leads to following error:C:\Users\Bozo\Documents\Data\Game Dev\Godot\ListsNotWorking\lists_not_working.cs(8,53): The type of the exported field is not supported: 'lists_not_working.listOfString'
Expected Behaviour Being able to change the list via the Inspector like you would do with arrays. (Or like you could in Godot 3.5 with List<>())
Minimal reproduction project
C#ListsNotWorking.zip