Godot-Mono-CustomResourceRegistry
Godot-Mono-CustomResourceRegistry copied to clipboard
[Export]ed property doesn't narrow down possible object types to CustomResource type
I've added a custom resource type and [Export]ed it in one of the scripts. When I'm assigning an object it shows me all possible resource types known to the engine
It's the same behaviour as I just make property type in a script as [Export] Resource myCustomResource
This is Godot's built in behaviour. This won't be fixed until we get first class support for C# resources.
See https://github.com/godotengine/godot/pull/72619.
In the mean time, you can assign a class prefix in the settings for this plugin. For example if you assign their prefix as _, all your custom resources will show up first.
Does it actually show up in the dropdown for you guys? I'm only seeing the custom resources in the file system's New Resource window.
Does it actually show up in the dropdown for you guys? I'm only seeing the custom resources in the file system's New Resource window.
Uh oh you're right it's missing. We should probably file a bug report on the godot repo.
I've made the issue here https://github.com/godotengine/godot/issues/75245, although once the C# first class resource support gets added, this plugin will be moot.
So until that issue is seen to or the C# first class resource support is finally merged (the former seems unlikely given the attention on the latter), our sole option for custom Resources written in C# is to create each instance individually through the filesystem's right click New > Resource menu and drag them into Inspector fields?
So until that issue is seen to or the C# first class resource support is finally merged (the former seems unlikely given the attention on the latter), our sole option for custom Resources written in C# is to create each instance individually through the filesystem's right click New > Resource menu and drag them into Inspector fields?
Yeah I guess you can no longer create local custom resources in scenes. Creating resources in the file system should still work.
Yeah I guess you can no longer create local custom resources in scenes. Creating resources in the file system should still work.
I've found a workaround that permits local custom resources, even with their being absent from the new resource dropdown menu:
- Create the custom resource through the FileSystem tab.
- Drag it into a Resource field in the Inspector.
- Make the resource unique by right clicking it and selecting Make Unique.
This will copy the resource's contents into the .tscn file as though it had been created from the dropdown. From there, more local instances can be conveniently created by copying, pasting, and making the pasted resource unique.
Thank you for creating this plugin, by the way - it's an important stopgap while the main project works out C# first class resource support.
If you're dealing with an exported array of custom resources, you can also add the [Tool] attribute and then write a setter property for the array which auto initializes empty elements. This means that when you press the Add Element button, an object will be created automatically. This won't really work for child classes though, unless you write an inspector plugin.