NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Debug/SROptions.Notice.cs

36 lines
1.1 KiB
C#

using System;
using System.ComponentModel;
using UnityEngine;
using Object = UnityEngine.Object;
public partial class SROptions
{
private UniWebView webView;
[Category("公告"), DisplayName("公告内容")] public string NoticeContent { get; set; }
[Category("公告"), DisplayName("显示测试公告")]
public void ShowDebugNotice()
{
try
{
var webViewGameObject = new GameObject("UniWebViewTest");
Object.DontDestroyOnLoad(webViewGameObject);
webView = webViewGameObject.AddComponent<UniWebView>();
webView.Frame = new Rect(0, 0, Screen.width / 2, Screen.height / 2);
webView.LoadHTMLString(NoticeContent, null, false);
webView.EmbeddedToolbar.Show();
webView.Show();
webView.OnShouldClose += (view) =>
{
webView = null;
Object.DestroyImmediate(webViewGameObject);
return true;
};
}
catch (Exception e)
{
DebugUtil.LogError("创建内置浏览器异常:{0}", e);
}
}
}