Classes that inherit from `PackedScene` in gdextension does not work with `tscn` files
Tested versions
- v4.8.dev.mono.custom_build [97dab7a63]
System information
Godot v4.8.dev.mono (97dab7a63) - 'Gentoo' '2.18' on Wayland - X11 display driver, Multi-window, 3 monitors (2560x1080 @ 74.94 Hz, 3440x1440 @ 159.86 Hz, 2000x1200 @ 59.91 Hz) - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4060 (nvidia; 595.84) - AMD Ryzen 5 5600 6-Core Processor (12 threads) - 15.54 GiB memory - PulseAudio (44100 Hz, Stereo/mono)
Issue description
In current master and since Godot 4.8-dev5, it is possible to create a script like this:
class_name CustomScene
extends PackedScene
@export var test: StringName
or csharp version:
using Godot;
using System;
[GlobalClass]
public partial class CustomScene : PackedScene
{
[Export] string test;
}
And then right clicking in filesystem clicking in new resource
And then selecting it trough the Create new resource dialogue
You can edit the scene in the editor perfectly fine and edit the properties by opening the scene in the inspector.
However. This doesn't work with gdextension:
#pragma once
#include "godot_cpp/classes/packed_scene.hpp"
#include "godot_cpp/classes/wrapped.hpp"
#include "godot_cpp/variant/string_name.hpp"
using namespace godot;
class CustomScene : public PackedScene {
GDCLASS(CustomScene, PackedScene)
StringName test_value;
protected:
StringName get_test_value() const;
void set_test_value(const StringName p_value);
static void _bind_methods();
};
#include "custom_scene.h"
#include "godot_cpp/variant/string_name.hpp"
StringName CustomScene::get_test_value() const {
return test_value;
}
void CustomScene::set_test_value(const StringName p_value) {
test_value = p_value;
}
void CustomScene::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_test_value"), &CustomScene::get_test_value);
ClassDB::bind_method(D_METHOD("set_test_value", "value"), &CustomScene::set_test_value);
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "test_value"), "set_test_value", "get_test_value");
}
The file can be created, but tscn files are missing the fields that identify the type, so the scene opens as if it was a regular scene.
This bug does not happen with binary files.
Steps to reproduce
setup a gdextension with godot.cpp with the code above
And then right clicking in filesystem clicking in new resource
And then selecting it trough the Create new resource dialogue
The resource will be saved as if it was a regular scene.
Minimal reproduction project (MRP)
I will try to compile the gdextension for windows editor, but for now only linux:
Source: godotengine/godot