Customizing browser choice for Start Server/Play

Hey guys, it’d be great to have an how (and when) the browser opens up.

Right now you’re opening the URL on Start Server and Play. This then starts a new tab on the default browser.

I’d like options in the settings to

  • Define when the URL is auto-opened
  • Optionally specify how to start the browser process: So I can put my own e.g. path/to/browser.exe -withArgs {0} .

Original Post on Discord

by user 395602247196737546

When pressing play and a server already being started we don’t open the URL again - is that not what you’re seeing?
(if a page is already reachable/connected there’s no need to open it again)

We’re using Unity’s Application.OpenURL at the moment to launch the page, which means we can’t pass arguments to it - typically we saw that people want it to launch in whatever your default browser setup is. And that browser then handles if that’s a new process, or a new tab, or … depending on the browser.

Would you mind elaborating a bit on what kind of parameters you’d like to pass along?

You’re right in that it opens only when the server is starting up.
I think it’s a bit of a naming/expectations thing :slightly_smiling_face: “Start server” sounds like it starts the server process but not necessarily connect to it.

by user 395602247196737546

But the main point is I want more control over what it does. Starting in the default browser is a good default, no doubt.
In my case though I use Firefox as my main browser for everything and use e.g. Chrome (or derivates) as my dev browser. This way, I can easily differentiate between my browsing area and my dev stuff.

by user 395602247196737546

I see, so you’d basically want to have something similar to how External Tools config in Unity works (choosing from a set of targets)?

Just personally I use multiple chrome profiles to separate this, and OpenURL opens in the last focused one

I’m not sure if we’d want to change the current behaviour but what I can look into is adding a callback before the page is opened that you could hook into and do “custom stuff” (launch in a new browser process, qutting the previous process and re-launching, launch in five browsers, print the URL, …) and prevent default behaviour if wanted

As for what arguments I’d like to pass along – it just felt like an appropriate thing to do when opening up to different ways to start up :slightly_smiling_face: I do not yet have the use case for passing arguments.
On the top of my head I can think of some stuff like --autoplay-policy=no-user-gesture-required for kiosk-like applications.

by user 395602247196737546

A callback would work. But why not leave the default as is and add an opt-in to specify a custom command?

by user 395602247196737546

That’s what I mean with callback. We wouldn’t want to build UI around something like this, it’s very project specific what you’d want to do

Yeah and user-specific, and also environment-specific. I sse. A callback sounds fine :wink:

by user 395602247196737546

Latest version has ActionsBrowser.BeforeOpen that you can use to customize what happens. Let me know if that is sufficient for your cases!

works wonders, thanks!

by user 395602247196737546

Great to hear - awesome!
Feel free to share a code snippet on the contributions page if you feel it would be useful to others :slightly_smiling_face:

ActionsBrowser disappeared :frowning_with_open_mouth:

by user 395602247196737546

sorry, strike that. just VS’s cache.

by user 395602247196737546