You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Godot:如何设置特定节点Editable Children默认启用或简化开启操作?

针对Godot中特定场景默认启用Editable Children的解决方案

一、简化开启Editable Children的快速操作

  • 快捷键直接切换:选中场景根节点后,按下Ctrl+Shift+E(Windows/Linux)或Cmd+Shift+E(Mac),一键切换Editable Children的状态,比手动找菜单高效很多。
  • 自定义编辑器脚本一键触发:写个简单的编辑器脚本,针对指定场景快速开启状态,还能绑定自定义快捷键:
@tool
extends EditorScript

func _run():
    var selected_nodes = get_editor_interface().get_selection().get_selected_nodes()
    if selected_nodes.size() == 0:
        return
    var root_node = selected_nodes[0]
    # 匹配目标场景文件名,比如hitbox.tscn
    if root_node.scene_file_path.get_file() == "hitbox.tscn":
        root_node.set_editable_children(true)
        print("已为hitbox.tscn开启Editable Children")

将脚本保存后,在编辑器里通过Editor > Run Editor Script执行,还能在编辑器设置的快捷键面板中给“Run Editor Script”绑定专属按键,进一步简化操作。

二、近似实现“默认启用”的替代方案

目前官方确实没有直接给特定场景设置Editable Children默认启用的选项,但可以通过以下方式间接实现:

  • 使用场景模板:先创建一个已经开启Editable Children的hitbox模板场景,之后所有新的hitbox相关场景都从这个模板创建,省去重复开启的步骤。
  • 编辑器插件自动触发:编写一个轻量插件,监听场景加载事件,检测到目标场景时自动开启状态:
@tool
extends EditorPlugin

func _enter_tree():
    # 监听场景加载完成事件
    get_editor_interface().get_scene_tree_editor().connect("scene_loaded", self, "_on_scene_loaded")

func _on_scene_loaded(scene):
    var root = scene.get_root()
    # 匹配目标场景文件名
    if root.scene_file_path.get_file() == "hitbox.tscn":
        root.set_editable_children(true)

func _exit_tree():
    # 退出时断开连接,避免内存泄漏
    get_editor_interface().get_scene_tree_editor().disconnect("scene_loaded", self, "_on_scene_loaded")

将插件放到项目的addons文件夹下,在编辑器的插件面板启用后,每次打开hitbox.tscn都会自动开启Editable Children。

内容的提问来源于stack exchange,提问作者Racid

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 12:10:18