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.

in Engine by (26 points)

2 Answers

+1 vote
Best answer

On the EditorPlugin, call:


Where str, a String, is the name of the main screen you want to switch to.

by (60 points)
selected by
+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
by (3,350 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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.