Files
Webview_SgConfig_Unity_IOS/Assets/Scripts/OpenBrowser.cs
T

23 lines
537 B
C#
Raw Normal View History

2026-05-15 16:15:09 +08:00
using System.Runtime.InteropServices;
using UnityEngine;
public class OpenBrowser
{
2026-07-06 16:31:08 +08:00
[DllImport("__Internal")]
public static extern void _openURL(string url);
2026-05-15 16:15:09 +08:00
public static void OpenURL(string url)
{
// 调用iOS原生方法打开URL
2026-07-06 16:31:08 +08:00
if (Application.platform == RuntimePlatform.IPhonePlayer)
{
_openURL(url);
}
else
{
// 在非iOS平台上,你可以使用Unity的Application.OpenURL方法
2026-05-15 16:15:09 +08:00
Application.OpenURL(url);
2026-07-06 16:31:08 +08:00
}
2026-05-15 16:15:09 +08:00
}
}