Skip to content

Instantly share code, notes, and snippets.

@mrcdk
Created October 22, 2023 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrcdk/f7abedf934471e9ad227853416636f50 to your computer and use it in GitHub Desktop.
Save mrcdk/f7abedf934471e9ad227853416636f50 to your computer and use it in GitHub Desktop.
Godot 4.1 open the project settings and select an entry
@tool
extends EditorScript
func _run() -> void:
var interface = get_editor_interface()
var base = interface.get_base_control()
# Find the Project Settings Editor
var settings = base.find_child('*ProjectSettingsEditor*', true, false)
if not settings:
print('ProjectSettingsEditor not found (?)')
return
# Grab the tab container from the sectioned editor
var tab_container = settings.find_child('*TabContainer*', true, false)
if not tab_container is TabContainer:
print('Could not find the tab container')
return
# Set the current tab to General
tab_container.current_tab = 0
# Find the Sectioned Editor inside it
var sectioned_inspector = tab_container.find_child('*SectionedInspector*', true, false)
if not sectioned_inspector:
print('SectionedInspector not found (?)')
return
# Find the Tree inside it
var tree = sectioned_inspector.find_child("Tree", true, false) as Tree
if not tree:
print('Could not find Tree')
return
# Find the entry in the tree
var found_item = null
var item = tree.get_root()
while item:
item = item.get_next_visible()
if not item:
print('--finished')
break
if item.get_text(0) == "2D Render":
found_item = item
break
# Select the found item
if found_item:
tree.set_selected(found_item, 0)
tree.ensure_cursor_is_visible()
# Finally popup the Project Settings Editor
settings.popup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment