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

resource_name and resource_path = empty strings #56177

Open
Torguen opened this issue Dec 22, 2021 · 7 comments
Open

resource_name and resource_path = empty strings #56177

Torguen opened this issue Dec 22, 2021 · 7 comments

Comments

@Torguen
Copy link

Torguen commented Dec 22, 2021

Godot version

3.4.1 stable

System information

w10 64

Issue description

I am trying to identify who emits the events that occur when touching the screen, on buttons like "TouchScreenButton".
For this I use "resource_path" and "resource_name" in "_input" but they are empty strings, you cannot identify who is emitting the event because they are empty strings.

Steps to reproduce

In "_input" check who issued the event using what I said before.

Minimal reproduction project

No response

@Torguen Torguen changed the title resources of events emptys resource_name and resource_path = empty strings Dec 22, 2021
@Calinou
Copy link
Member

Calinou commented Dec 22, 2021

@Torguen Please upload a minimal reproduction project to make this easier to troubleshoot.

TouchScreenButton is a node, not a resource. It does not have a concept of resource name and resource path in its instanced form. However, a PackedScene is a resource, so it can have a name and path defined. The name is empty by default, but you can specify it manually in the inspector. The path is empty for built-in resources, and is set to a res:// path for resources saved to a file.

@AnidemDex
Copy link

AnidemDex commented Dec 22, 2021

I don't understand this issue. InputEventButton doesn't inherits from Resource and InputEventActions usually are not saved to the FileSystem (and, since are not saved, they doesn't have any resource_path or resource_name) and if that were the case, that action is not a clear way to know what InputEventButton was pressed.

@Torguen
Copy link
Author

Torguen commented Dec 23, 2021

The issue is that I wanted to know who is emitting the event and I thought that resource_path or name could tell me the node that is emitting but it is not. So I thought the problem was that the strings are empty.

Maybe this is not a bug.

There is really no way to know who is throwing the event in "_input".
"event" does not have that information.

@Torguen
Copy link
Author

Torguen commented Jun 30, 2023

v3.6.beta2.official [68c507f]
resource.resource_name still does not print any information
resource.resource_path works

a scene was loaded but the name of the resource is not printed:

var nivel_cargado = loader.get_resource()
print( nivel_cargado.resource_name )

@hsandt
Copy link
Contributor

hsandt commented Feb 15, 2024

a PackedScene is a resource, so it can have a name and path defined

May I ask how to set the resource_name of a PackedScene? Double-clicking on a scene doesn't open it as a resource in the inspector, unlike other types of resources (it just opens the scene). The only time I can see the inspector showing PackedScene content is during debug, if I have a packed_scene var, by clicking on it in the Debugger. But changing the resource name there won't be saved (maybe because it's remote? the effect is similar to the issue linked above, but for PackedScene and during debug).

Otherwise, my PackedScene resource_path is correctly set. So to debug that specific bug we'll need a MWE or steps to reproduce the issue from a new project.

@AnidemDex
Copy link

May I ask how to set the resource_name of a PackedScene?

var packed_scene = load("res://my_packed_scene.tscn")
packed_scene.resource_name = "Original Name"

Double-clicking on a scene doesn't open it as a resource in the inspector,

This is because the edit behavior of a PackedScene is opening it in scene editor (the editor made specifically for packed scenes).

The only time I can see the inspector showing PackedScene content is during debug

This is because you're inspecting the scene as a resource, you're not editing the scene as resource. Are you sure this issue is related to your issue @hsandt ?

@hsandt
Copy link
Contributor

hsandt commented Sep 22, 2024

May I ask how to set the resource_name of a PackedScene?

var packed_scene = load("res://my_packed_scene.tscn")
packed_scene.resource_name = "Original Name"

Thanks, so runtime code, it explains how it could happen.

Double-clicking on a scene doesn't open it as a resource in the inspector,

This is because the edit behavior of a PackedScene is opening it in scene editor (the editor made specifically for packed scenes).

Yes, this makes sense.

The only time I can see the inspector showing PackedScene content is during debug

This is because you're inspecting the scene as a resource, you're not editing the scene as resource. Are you sure this issue is related to your issue @hsandt ?

I don't have an issue with this in particular, I was just curious about how OP could reach the situation they described (so ultimately get the repro steps). Well, technically I had a few issues related to resource names but they were quite different and just led me to find this ticket while searching for keywords. I don't remember exactly which ones but I probably fixed them / found a workaround at some point because I don't remember getting stuck on them.

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

No branches or pull requests

4 participants