docs
Getting Started
Tutorials
How-To Guides
Explanation
Reference
Help
Getting Started
Tutorials
How-To Guides
Explanation
Reference
Help
◀ Overview
profile imagekrisrok
View on Github
Always open in specific browser

Add this class to your project to always open with Chrome instead of your default browser (Firefox in my case) when you click "Play" or "Start Server". Note: This is an editor class and should either be put into an editor-only assembly or wrapped in #if UNITY_EDITOR and #endif.

using System.Diagnostics;
using UnityEditor;
using UnityEngine;
using Needle.Engine;

[InitializeOnLoad]
public static class CustomBrowserOpen
{
    static CustomBrowserOpen()
    {
        Init();
    }

    [RuntimeInitializeOnLoadMethod]
    static void Init()
    {
        ActionsBrowser.BeforeOpen += ActionsBrowser_BeforeOpen;
    }

    private static void ActionsBrowser_BeforeOpen(ActionsBrowser.OpenBrowserArguments args)
    {
        args.PreventDefault = true;
        string processArgs = args.Url;
        var psi = new ProcessStartInfo
        {
            FileName = "chrome.exe",
            Arguments = processArgs
        };
        Process.Start(psi);
    }
}
Add your contribution

Extras

ChatGPT Ask ChatGPT Claude Ask Claude
Copy Markdown

Navigation

  • Getting Started
  • Tutorials
  • How-To Guides
  • Explanation
  • Reference
  • Help

Extras

ChatGPT Ask ChatGPT Claude Ask Claude
Copy Markdown