I am trying to export a Godot game to Android using C#. I am using external libraries, like onnxruntime and everything seems to work except for the fact that I cannot include custom files to the exported package. I have already tried to include custom files using Godot's built in resources tab in the export dialog. More specifically, I have added *.txt and *.onnx as extensions to be included. However, only .txt files are exported and recognized. I can get a .txt file by using the res:// location, but other files cannot be found, because they "don't exist". So, how can I access custom files? Where do I have to place them and how do I reference them? Is there a library I have to install? Do I have to fiddle with the AndroidManifest or gradle files? I am using Godot 3.5, Visual Studio Code and .NET 6.0. Any help is appreciated.
Asked
Active
Viewed 208 times
0
-
1I know there have been bugs regarding exporting non-resource files. Can you make minimal project? Anyway, the workaround would be to make them resource files, which means to implement custom `EditorImportPlugin`. – Theraot Nov 25 '22 at 23:10
-
@Theraot, it seems the problem was with the way I was trying to access the files, not with the inability of the system to include them. While I cannot reference the files using the path res:// and C#'s File management system, I was able to use Godot's built in File to load the files. Otherwise I would get a "Nonexistent file" error or something similar. Having said that, thank you for your answer, I think it is worth investigating EditorImportPlugin in the future. I am turning my solution into an answer now. – J. Fenigan Dec 02 '22 at 20:23
1 Answers
0
At first I tried to change the extension of the files into .res in order to trick the system into accepting them. However, while the files could be seen by Godot, importing and using them proved to be tricky. Instead I used Godot's File functionality after I had declared the extensions that I wanted to use in the resources tab, in the Export dialog. This code works:
var f = new Godot.File();
f.Open(m_path, Godot.File.ModeFlags.Read);
res = f.GetBuffer((long)f.GetLen());
f.Close();
I have not figured out why the path res://[filename.extenion] returns no results though.

J. Fenigan
- 119
- 2
- 9