godotengine / godotengine/godot
Scene state is missing value after property passed to local_to_scene ShaderMaterial
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
v4.2.2.stable.official [15073afe3]
v4.3.rc3.official [03afb92ef]
### System information
Ubuntu
### Issue description
This is not super straight forward to explain so I'll have to rely on the MRP.
In essence, I do this:
```gdscript
var packed_scene = preload("res://entity.tscn")
print(packed_scene.get_state().get_node_property_value(0, 2))
```
prints:
```
[1, 2, 3]
```
Then a moment later that code is ran again, but prints:
```
[]
```
### Steps to reproduce
Here's what happens in the MRP:
1. We preload a `tscn` file.
2. The `tscn` file contains a node with an array property `my_prop` and a serialized value: `my_prop = Array[int]([1, 2, 3])`
3. We instantiate from the packed scene, add the resulting node instance to the tree, and pass the aforementioned property into `material.set_shader_parameter()` where `material` is a `ShaderMaterial` that has `local_to_scene` set to `true`.
4. We reload the current scene, bringing us back to step 1. again, only this time the packed scene state is faulty: the value of my `my_prop` is an empty array.
### Minimal reproduction project (MRP)
[godot_4_packed_scene_values_missing_bug.zip](https://github.com/user-attachments/files/16571127/godot_4_packed_scene_values_missing_bug.zip)
Contributor guide
Research direction
Start with the attached minimal reproduction project and trace the packed scene state across the reload after the ShaderMaterial with local_to_scene enabled receives the array through set_shader_parameter(). Verify the behavior using get_node_property_value(0, 2); done means the serialized my_prop value remains [1, 2, 3] rather than becoming an empty array.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100