Drag the ButtonOpenURL Script on a Unity UI Button, define the Url to Open and the Script will automatic attach a onClick Event that performs the Application.OpenURL Action to Open a Unity URL
ButtonOpenURL.cs
using UnityEngine;
///
/// Attached on a Unity UI Button the Click on it with Call the URL to Open
///
public class ButtonOpenURL : MonoBehaviour
{
[SerializeField] string urlToOpen = "https://www.stussegames.com";
void OnEnable() =>
GetComponent().onClick.AddListener(OpenURL);
void OpenURL() =>
Application.OpenURL(urlToOpen);
void OnDisable() =>
GetComponent().onClick.RemoveListener(OpenURL);
}
The ButtonOpenURL Script can be also changed and a Button variable can be attached and assigned inside the Inspector to remove the GetComponent Part from t he OnEnable and OnDisable Function.
Its also Possible to make the OpenURL Method Public and call it from another Script or Assign it inside the Unity Inspector on the Button onClick Events.