Library for opening web browser windows on various platforms from Unity.
This repository is a Unity package. Add it as a Git package to your project from the Package Manager.
If you plan to develop for Android, install Google's External Dependency Manager and resolve Android packages to install the native dependencies.
Simply call BrowserWindow.Open
to open a URL:
string repo = "https://github.com/githubcatw/BrowserWindow";
BrowserWindow.Open(repo);
You can also check out the wiki for full documentation. If you prefer learning by example or want to look at an example of usage check out the Basic Sample provided with the package.
Browser windows can be customized, with different settings depending on the platform. For this an object with the class BrowserWindow
needs to be created, as well as a platform-specific configuration.
Here's an example for changing colors of Chrome custom tabs on Android:
// Create an Android configuration
BWAndroidConfig androidConfig = new BWAndroidConfig();
// Set the color of the window to blue
androidConfig.SetColor(Color.blue);
// Create a BrowserWindow object and set the Android config
BrowserWindow window = new BrowserWindow();
window.SetAndroidConfig(androidConfig);
After that it's as simple as calling CustomOpen
on the object to open a URL with the preferred settings:
string repo = "https://github.com/githubcatw/BrowserWindow";
window.CustomOpen(repo);
In this example, the code above will launch a blue custom tab pointing to this repository on Android, and a regular browser window on other platforms.
For more information about customization check out the wiki page on platform specific customization.
A. Currently the library supports:
- Chrome custom tabs on Android,
SFSafariViewController
on iOS,- Unity's
Application.OpenURL
method on other platforms.
A. Enable the custom proguard-user file if it's off, and add this to Plugins/Android/proguard-user.txt
:
-keep public class dev.torosyan.** { *; }
A. Browser Window is licensed under the MIT license, meaning that you can use it in a closed source project. If you make changes and think that other developers might like them too, feel free to contribute.