This is an update to Steven Vroom's answer to contemplate a few circumstances and correct some steps
Given a parentclass.tscn file and a subclass.tscn file, where subclass.tscn doesn't currently inherit parentclass.tscn, but you want it to.
The steps are as follow:
- Backup the subclass.tscn file
You'll need to revisit it to look at the node order if it has any, or if it matters, given the process will change the order of inherited nodes
- Open the subclass.tscn file in a text editor
- Add the following line (doesn't matter where)
[ext_resource path="res://path/to/parentclass.tscn" type="PackedScene" id=${id}]
Replace ${id}
by an id not currently in use by another ext_resource
(if you have 3 ext_resources
, with ids 1,2,3, then ${id}
could be 4 and the line would read [ext_resource path="res://path/to/parentclass.tscn" type="PackedScene" id=4]
).
- Edit the root node
[node name="subclass" type="RigidBody2D"]
↓↓↓
[node name="subclass" instance=ExtResource( ${id} )]
- If subclass.tscn has nodes that parentclass.tscn also has, remove their type/instance tag
[node name="some_node" parent="." instance=ExtResource( 16 )]
↓↓↓
[node name="some_node" parent="."]
and
[node name="some_other_node" parent="." type="Area2D"]
↓↓↓
[node name="some_other_node" parent="."]
- Save the file
- Open it on the editor
- Reorder the nodes in the order they originally were
This is where the backup made on the first step comes in. Given the scene will have been reordered in a way that inherited nodes appear first in the list, you'll need to save or remember the order they were in pre-inheritance, to reset it (omit this if the order doesn't matter in this case).
- Save the scene
That's it. The file will now have been fixed by the editor to eliminate unnecessary references and the load_steps will have been updated