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

ResourceName not saved #82333

Closed
BorisTheBrave opened this issue Sep 25, 2023 · 6 comments · Fixed by #82406
Closed

ResourceName not saved #82333

BorisTheBrave opened this issue Sep 25, 2023 · 6 comments · Fixed by #82406

Comments

@BorisTheBrave
Copy link
Contributor

Godot version

v4.1.1.stable.mono.official [bd6af8e]

System information

Godot v4.1.1.stable.mono - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1070 (NVIDIA; 30.0.14.9613) - Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (6 Threads)

Issue description

Setting the resource name of a packed scene does nothing. It displays in the editor, but checking the resource_name field just gives "" and if you restart the editor your setting is gone.

This is rather unreliably to reproduce, but I eventually got the attached minimal project where it happens reliably.

This is probably the cause of #56177 and #41619, but it's hard to be sure.

Steps to reproduce

  1. Open attached project
  2. open test_scene, select the Sprite2d node in editor.
  3. Enter some_value in the name of the resource of the asdf field of the attached script.
    image
  4. Run scene.
    Expected: Console Prints "resource_name is some_value"
    Actual: Conole Prints "resource_name is "
  5. Save everything, restart the editor
  6. inspect the Sprite2d again
    Expected: Resource name should be some_value
    Actual: Resource name is empty

NB: Saving the scene or saving the resource seem to make no difference.

Minimal reproduction project

ResourceNameIssue.zip

@dylancusson
Copy link

I can't find any reference to resource_name in packed_scene, node, or resource.cpp or .h files. Each file has some references to a name property though and associated set/get functions.

The name can be set by calling asdf.set_name("nametoset") in the script and then read with asdf.get_name().

I'm guessing we'd either need to add a set/get function for resource_name, or change the Inspector behavior to reference the established name properties.

@ErezShahaf
Copy link
Contributor

ErezShahaf commented Sep 26, 2023

I can't find any reference to resource_name in packed_scene, node, or resource.cpp or .h files. Each file has some references to a name property though and associated set/get functions.

The name can be set by calling asdf.set_name("nametoset") in the script and then read with asdf.get_name().

I'm guessing we'd either need to add a set/get function for resource_name, or change the Inspector behavior to reference the established name properties.

I don't think that there is anything missing as the creator of the issue said that "This is rather unreliably to reproduce, but I eventually got the attached minimal project where it happens reliably." Implying that it does work in other projects.

@dalexeev
Copy link
Member

Not all resource formats support storing the resource name. For example, if you enter a name in the following field, save the resource, and restart the editor, the name will be lost because *.gd files only store the source code and no other metadata.

Resource (*.tres):

[gd_resource type="Resource" format=3 uid="uid://c4k36vqy48njh"]

[resource]
resource_name = "test"

Scene (*.tscn):

[gd_scene load_steps=2 format=3 uid="uid://wg043njbrkf3"]

[ext_resource type="Script" path="res://test.gd" id="3_1geoe"]

[node name="Node" type="Node"]
script = ExtResource("3_1geoe")

We could add an optional name attribute:

[gd_scene load_steps=2 format=3 uid="uid://wg043njbrkf3" name="test"]

@BorisTheBrave
Copy link
Contributor Author

Ok, so it's impossible to fix for all resources (as it'll never work for script resources?). Perhaps it would be better to disable the field if it's not going to work?

@BorisTheBrave
Copy link
Contributor Author

In fact, all this has been discussed before.
#43809
#13358

Resolution then was "docs already explain this, we don't want to remove it, and we don't want to support it everywhere". Not very satisfying in my opinion, particularly as imho it is not documented.

@dalexeev
Copy link
Member

dalexeev commented Sep 26, 2023

Perhaps it would be better to disable the field if it's not going to work?

To do this properly, a _is_support_resource_name() virtual method would be required for ResourceFormatLoader/ResourceFormatSaver. But in my opinion this is overkill. Another option is to hardcode resource types that do not support names.

@akien-mga akien-mga added this to the 4.2 milestone Nov 1, 2023
orianbsilva pushed a commit to orianbsilva/godot that referenced this issue Nov 1, 2023
Closes godotengine#82333.

Co-authored-by: Yuri Sizov <11782833+YuriSizov@users.noreply.github.com>
GuybrushThreepwood-GitHub pushed a commit to GuybrushThreepwood-GitHub/godot that referenced this issue Jan 27, 2024
Closes godotengine#82333.

Co-authored-by: Yuri Sizov <11782833+YuriSizov@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants