Version: 2023.1
言語: 日本語
public static void OpenURL (string url);

パラメーター

url The URL to open.

説明

Opens the URL specified, subject to the permissions and limitations of your app’s current platform and environment.

This is handled in different ways depending on the nature of the URL, and with different security restrictions, depending on the runtime platform.

Note: The OpenURL method can be used to open more than just web pages; therefore, ensure that you're aware of the security implications involved before using this method. This method is used to open HTTP (web page) URLs. If you provide a web page address as the parameter for this method, the web page opens in the default browser and display the browser application in the front.

In addition to the HTTP protocol used for web browsers, you can use other protocols in a URL, such as file transfer (FTP), email (mailto), database access (JDBC), and others platform-specific protocols. On some platforms, you can use OpenURL to do different types of tasks in Unity.

The OpenURL command is powerful and on some platforms, it can even open local files, run commands, and open connections over any protocol that the platform and security sandbox supports.

The OpenURL method runs with the same permissions as your app itself. For example, if your app is running as a WebGL player in a desktop web browser, it cannot access local files on the machine, because the WebGL platform runs inside a security sandbox which prevents that. However, this method is more powerful on platforms such as a desktop platform exe app, where it runs with fewer security restrictions without a security sandbox.

Important: Be cautious and do NOT pass a string to the OpenURL function to prevent any malicious attempts from third-party software.

On desktop platforms, you should consider this method to have similar security implications as an eval type function, which is present in most programming languages.

If your app uses OpenURL to open URL strings from a third-party, or the strings put together using any user-supplied data, then that data should be considered untrusted and used to run arbitrary code under the same permissions of your app. You must also sanitise the untrusted data and validate to ensure that it generates the expected input for your application.

WebGL: From version 2019.4.25f1, 2020.3.5f1, 2021.1.2f1, and 2021.2.0a11, Application.OpenURL opens url in a new browser tab. In previous versions,Application.OpenURL opened url in the same browser tab, which terminates the active Unity application.

Android: Due to security changes in Android 7.0 (More information), Application.OpenURL can no longer be used for opening local app files. To share files with other applications, you must use (FileProvider).

iOS: Application.OpenURL cannot be used for opening local files.

Example:

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Start() { Application.OpenURL("http://unity3d.com/"); } }