我想創建一個簡單的應用程序,它捕捉到剪貼板(按Ctrl + C)網址鏈接,並打開他們在一個窗口(也關閉的時候,打開的窗口)。Unity3D - Webplayer不會在後臺運行(但設置設置...)?
我做了一個非常簡單的腳本:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
public class ClipboardWebpage : MonoBehaviour {
List<string> openedWindows = new List<string>();
void OpenNewPage(string url) {
string name = "window";
openedWindows.Add(name);
Application.ExternalEval("var " + name + " = window.open('" + url + "', 'title')");
}
void Start()
{
Application.runInBackground = true;
}
string lastCheck = "";
void Update() {
string clip = getClipboard();
if (!lastCheck.Equals(clip))
{
lastCheck = clip;
Uri uriResult;
bool result = Uri.TryCreate(lastCheck, UriKind.Absolute, out uriResult)
&& (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
if (result)
{
CloseAll();
OpenNewPage(lastCheck);
}
}
}
void CloseAll()
{
foreach (string name in openedWindows)
{
Application.ExternalEval(name + ".close()");
}
}
string getClipboard()
{
return GUIUtility.systemCopyBuffer;
}
void setClipboard(string value)
{
GUIUtility.systemCopyBuffer = value;
}
}
的問題是,在Web Player不運行這段代碼,當它沒有專注......(在後臺運行選項設置代碼和也是在播放器設置...)
有誰知道,如何解決我的問題呢?
謝謝!
只檢查已更改Web播放器播放器設置爲在後臺運行,而不是一個不同中等錯誤? – Zze
我現在檢查了兩次,以確保。但的確,該設置是設置... – 3DExtended