OpenNewTabPlugin.jslib ※UTF-8Unity記事: 目次
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
/* Unity 2018.2.11f1 jslib Plugin for WebGL 設置場所: Assets/Plugins/WebGL/ */ var OpenNewTabPlugin = { OpenNewTab: function(URL) { var url = Pointer_stringify(URL); window.open(url); } } mergeInto(LibraryManager.library, OpenNewTabPlugin); |
OpenURL.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
using System.Runtime.InteropServices; using UnityEngine; /// <summary> /// /// Unity 2018.2.11f1 /// /// </summary> public class OpenURL : MonoBehaviour { // Plugins [DllImport("__Internal")] private static extern void OpenNewTab(string URL); // URL private readonly string url = "https://gamefbb.com/"; // 開くボタンを押したときの処理 public void ClickOpenButton() { OpenWindow(); } // 外部ブラウザでURLを開く private void OpenWindow() { #if UNITY_EDITOR Application.OpenURL(url); #elif UNITY_WEBGL OpenNewTab(url); #else Application.OpenURL(url); #endif } } |