godotengine / godotengine/godot-docs

Exporting a string array for File property hint in C# does not show up in file editor

Open
#11,655 5 comments 0 reactions 0 assignees View on GitHub
area:manual discussion topic:dotnet
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

**Your Godot version:**
.NET v4.5

**Issue description:**
When trying to export an array of strings with the property hint for files, Godot will not show a list of available files in the editor. Instead, it tries to open Resource files. For example, in the code below I'm trying to get an array of strings so I can choose JSON files for dialogues:

```[Export(PropertyHint.File, "*.json,")] private string[] GameFile = [];```

However, when trying to open the file editor using quick load it is trying to search for a resource file instead of a json.

Image

When trying to load the files manually the console is giving out this error:

Image

Doing the equivalent in GDScript which seems to work just fine.

```@export_file("*.json") var dialogues : PackedStringArray = []```

Image

I have also tried using Godot.Collections.Array approach. While it does allow you to provide paths to the files in the editor, you have to manually type or copy the file paths instead of being able to select it in the file editor.

```[Export(PropertyHint.File, "*.json,")] private Array GameFile = [];```

Image

The documentation for C# exported properties does not have an example for exporting an array of string paths but GDScript documentation does. When asking on the official Discord server I was told this is most likely a bug. Is this a bug or perhaps using the wrong syntax?

**URL to the documentation page:**

https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_exports.html

https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_exports.html

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.