1090405 從Unity透過Button開啟外部網頁
by 黃國哲
2020-04-05 22:40:07, 回應(0), 人氣(3522)


插入Button之後,要將以下的程式先建入Canvas (UI的活動區塊內),
再將Canvas插入各個Button的Script,之後選擇WebURLScript功能,然後分別各個按鈕選擇btnOne...etc
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class WebURLScript : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
public void btnOne()
{
Application.OpenURL("http://google.com/");
}
public void btnTwo()
{
Application.OpenURL("http://unity3d.com/");
}
// Update is called once per frame
void Update()
{
}
}
回應