Search code examples
user-interfacegodotgdscript

Making a one-click hyperlink software in godot


I want to make a multi-device software with godot that allows you to enter to a specific webpage that is recorded. I mean, you press a button, then a container appears, in the container you write the page and then, every time you touch the software icon, it automatically takes you to the page. But I have no idea how to do it.

All the code I have is:

func _on_Button_pressed():

OS.shell_open("webpage")

inside a button node.


Solution

  • So the user opens your application and it immediately redirects to a saved URL if there is one, otherwise it prompts them to pass in a URL.

    You could use a generic Node when you first load the app in order to determine whether to redirect or prompt for a URL.

    It's pseudo code, but the main scene might look something like this:

    extends Node
    
    func _ready():
        var saved_url = Persistence.load_saved_url()
        if saved_url != null:
            OS.shell_open(saved_url)
        else:
            get_tree().change_scene("res://AskForURL.tscn")
    

    Of course, you'll need to actually implement persistence. And you might want to consider a way for them to edit the url if they type it in wrong, rather than redirecting immediately.