I can't find a structure representing a file in Godot to use in the editor
I want to add a property to my Node something like:
[GlobalClass]
public partial class MyObj : Node2D
{
[Export] public File myFile;
...
It should be possible to pick a file (a file location) and assign it to that variable, is it possible?
No structure. String
. For example:
[Export(PropertyHint.File)]
public string GameFile { get; set; }
Source: Strings as paths
From comments, it seems you want a Resource
, when in Godot 4, you should be able export that directly. The documentation has the next couple examples.
Accept any Resource
:
[Export]
private Resource Resource;
Accept only AnimationNode
:
[Export]
private AnimationNode Resource;
See Resources. It is on the same page as the linked above, but further down.
I want to clarify that this works with any built-in resource, for example if you want a scene, you can do this:
[Export]
private PackedScene Resource;
And if you create a new class that extends from Resource
it should work with that class too. For example for MyResource
you do this:
[Export]
private MyResource Resource;