+2 votes

I created a custom resource with a C# script containing a class that extends Resource. I am able to create a resource file (.tres) using the file loading function in the engine (to load C# resource script), but the class name for the C# resource does not show up in "Create new Resource" dialog.
This is problematic because while I can create resources based on the script and save them as files, I can't create one as a SubResource to a scene. As an example, I create a script to a Node that has an export variable to my custom C# resource, and after I compile and click on the field corresponding to the variable in the inspector, a long list of Resources show up that contains options like:

New Animated Texture
New Animation
...
New World

----------------
Load

where my C# resource doesn't show up. I have to "Load" my resource file to set the field but then it overrides the properties of the resource file that I loaded.
As a test, I created a GDScript resource and it showed up on the list as "New " and I was able to create a sub-resource for it in the scene.
For the time being I'm manually editing my scene file to replicate it like:

...
[ext_resource path="res://path/to/MyResource.cs" type="Script" id=<x>]
...
[sub_resource type="Resource" id=<y>]
script = ExtResource( <x> )
<Field1> = <Value1>
...
[node name=<MyNode> type="Node" parent="."]
script = ExtResource( <z> )
<ResourceField> = SubResource( <y> )
...
asked May 3 in Engine by realManix (14 points)

1 Answer

0 votes

Afaik, it's still not implemented well for c#. It was one of the main reasons why I opted to go with GDScript on my first two games last year, when starting out.

Anyway, here's the github link to the issue, which is still open:
https://github.com/godotengine/godot/issues/27470

answered May 21 by Paterno (14 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.