修改细节,开始搞pc

This commit is contained in:
Caiyanpeng committed 2022-02-18 18:12:31 +08:00
1 parent 365fab22d4
commit 2c7d02ec9a
12 files changed
+2859 -254

No files matched your search

@@ -25,16 +25,22 @@ public class ActivityController : PFUIPanel
//Invoke("StartPageFunc",0.5f);
}
private void StartPageFunc()
private void StartPageFunc(Action action = null)
{
Debug.Log("开始");
// Load a URL.
webView.Frame = new Rect(0, 0, Screen.width, Screen.height);
webView.ReferenceRectTransform = browser.GetComponent<RectTransform>();
webView.SetUserAgent($"UniWebView {Application.platform} {Application.version}");
webView.BackgroundColor = Utils.HexToColorHtml("#23232d");
webView.Load(url);
if (action == null)
{
webView.Load(url);
}
else
{
action.Invoke();
}
// Show it.
webView.Show();
webView.OnMessageReceived -= FromJs;
@@ -50,11 +56,6 @@ public class ActivityController : PFUIPanel
case "OpenUrl": OpenUrl(message.Args); break;
default:break;
}
//if (message.Path.Equals("Close"))
//{
// Debug.Log(message.Args["msg"]);
// //transform.Find("Text").GetComponent<Text>().text = message.Args["msg"];
//}
}
private void OpenUrl(Dictionary<string, string> args)
@@ -78,7 +79,7 @@ public class ActivityController : PFUIPanel
else
{
UnityEngine.GUIUtility.systemCopyBuffer = url;
browser.GetComponent<UniWebView>().EvaluateJavaScript("window.postMessage(\"webview;复制成功\")");
RunJavaScript("window.postMessage(\"webview;复制成功\")");
}
}
@@ -99,6 +100,11 @@ public class ActivityController : PFUIPanel
CancelInvoke("StartPageFunc");
Close();
}
private void RunJavaScript(string js)
{
browser.GetComponent<UniWebView>().EvaluateJavaScript(js);
}
// Update is called once per frame
void Update()
{
@@ -108,10 +114,6 @@ public class ActivityController : PFUIPanel
public void Initial(string url)
{
this.url = url;
Debug.Log(this.url);
StartPageFunc();
return;
if (this.url != url)
{
this.url = url;
@@ -120,6 +122,10 @@ public class ActivityController : PFUIPanel
else
{
//执行浏览器内刷新或者其他操作
StartPageFunc(()=>
{
RunJavaScript("window.postMessage(\"webview;Refresh\")");
});
}
}
}