0 votes

I've recently been trying to make plugins and I made a custom main screen (like 2D, 3D, Script). I want to know how to switch between screens through a script.

asked Oct 7, 2019 in Engine by GooglyCoffeeMeat (22 points)

1 Answer

+1 vote

As far as I know this would mean that you have to "mess" with the Editor itself. I think Zylann did some plugin which lets you view/debug the node structure of the Godot GUI. Perhaps that will help you to identify the nodes to target.

Be aware that this is basically hacking and there's no guarantee that the nodes will stay the same in newer Godot versions.

I once did some plugin code to close a scene tab. I don't know if it still works though. Just for an example:

func close_scene_tab(scenename):
    var res=findSceneTab(dock.get_tree().root,scenename.get_basename())
    if res!=null:
        print("closing scene tab: "+scenename)

#scenename without .scn/.tscn
func findSceneTab(node,scenename,spaces=""):
    var res=null

    if node is Tabs:
        print (node.get_class()+": "+node.get_name())
        for i in range(0,node.get_tab_count()):
            print ("Tab "+String(i)+"/"+String(node.get_tab_count())+":"+node.get_tab_title(i))
            if node.get_tab_title(i)==scenename:
                return {"node":node, "ix":i}

    #print (node.get_name())
    for N in node.get_children():
        res=findSceneTab(N,scenename,spaces+" ")
        if res!=null:
            return res

    return null
answered Oct 8, 2019 by wombatstampede (3,151 points)

Sorry, I forgot to tell what "dock" is. It is a little scene file from the plugin:

func _enter_tree():
    # When this plugin node enters tree, add the custom type

    dock = preload("res://addons/MaterialMigrateG3/MaterialMigrate.scn").instance()
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.