Godot Version
4.x
Question
Is there a way to get the bottom panel’s Control and thus figure out its visibility status. I am working on a plugin which hides the bottom panel. But ideally would like to know whether to restore the bottom panel to its original state when the plugin’s job is done.
There is a way to set the visible state the bottom panel using EditorPlugin.
hide_bottom_panel ( ) and make_bottom_panel_item_visible ( Control item ).
extends EditorPlugin
func hide_all():
has_all().visible=false
func show_all():
has_all().visible=true
func has_all():
return EditorInterface.get_base_control().get_node("@VBoxContainer@14/DockHSplitLeftL/DockHSplitLeftR/DockHSplitMain/@VBoxContainer@25/DockVSplitCenter/@EditorBottomPanel@6653")
func has_child():
return has_all().get_node("@VBoxContainer@6642")
func has_names(a:String):
return has_child().get_node(a)
func hide_child():
for i in has_child().get_children():
i.visible=false
func hide_names(a:String):
has_names(a).visible=false
func show_names(a:String):
hide_child()
has_names(a).visible=true
func hide_item(a:int):
has_child().get_child(a).visible=false
func show_item(a:int):
has_child().get_child(a).visible=true
func has_button():
return has_child().get_child(-1).get_child(0)
func hide_item_button(a:int):
has_button().get_child(a).visible=false
func show_item_button(a:int):
has_button().get_child(a).visible=true
Your solution works so that gave me an idea. Hardest part was figuring out the node name
. I took it a step further, as I don’t trust the internal numbered node names as the numbers can change. What I decided to do instead is to just search for a node name containing
EditorBottomPanel
starting at the base_control(). I guess there is always a chance of dupes so i may refine it further.
It’s a pseudo-recursive walk through the base control until it finds a match and then quits. Pretty fast for my purposes. Thanks again!
var base=EditorInterface.get_base_control()
var waiting := base.get_children()
while not waiting.is_empty():
var node := waiting.pop_back() as Node
if node.name.find("EditorBottomPanel") >= 0:
print(node)
# node.visible=not visible
break
else:
waiting.append_array(node.get_children())