Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Export]ed property doesn't narrow down possible object types to CustomResource type #11

Open
xahon opened this issue Mar 20, 2023 · 8 comments

Comments

@xahon
Copy link

xahon commented Mar 20, 2023

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

image

It's the same behaviour as I just make property type in a script as [Export] Resource myCustomResource

@Atlinx
Copy link
Owner

Atlinx commented Mar 20, 2023

This is Godot's built in behaviour. This won't be fixed until we get first class support for C# resources.

See godotengine/godot#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.

@Nikola526
Copy link

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.

@Atlinx
Copy link
Owner

Atlinx commented Mar 23, 2023

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.

@Atlinx
Copy link
Owner

Atlinx commented Mar 23, 2023

I've made the issue here godotengine/godot#75245, although once the C# first class resource support gets added, this plugin will be moot.

@dashdotdashdot
Copy link

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?

@Atlinx
Copy link
Owner

Atlinx commented May 6, 2023

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.

@dashdotdashdot
Copy link

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.

@Nikola526
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants