#123568·godot

在 gdextension 中继承自 `PackedScene` 的类无法与 `tscn` 文件一起使用

作者: leandro-benedet-garcia创建于 2026年9月17日更新于 2026年9月17日
标签bugtopic:editorneeds testingtopic:gdextension

问题描述

在当前主版本和自 Godot 4.8-dev5 以来,可以创建如下的脚本:

class_name CustomScene
extends PackedScene
@export var test: StringName

或者 csharp 版本:

using Godot;
using System;
[GlobalClass]
partial class CustomScene : PackedScene
{
[Export] string test;
}

然后右键单击文件系统,单击新资源 然后通过创建新资源对话框选择它 您可以在编辑器中完美地编辑场景,并通过打开场景在检查器中编辑属性。 然而,这对于 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();
};

内容来源: godotengine/godot