加入了浮动小游戏功能和设置界面
运行时请手动修改运行库目录fdBrowser
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using System.Diagnostics;
|
||||
using UnityEngine;
|
||||
|
||||
public class LaunchH5 : MonoBehaviour
|
||||
{
|
||||
public RectTransform panel; // 绑定 Panel
|
||||
public string hostPath = "WebView2Host/WebView2Host.exe"; // Host.exe 相对路径
|
||||
|
||||
void Start()
|
||||
{
|
||||
string h5Path = $"file:///{UnityEngine.Application.streamingAssetsPath}/H5/index.html";
|
||||
|
||||
Vector3[] corners = new Vector3[4];
|
||||
panel.GetWorldCorners(corners);
|
||||
int x = Mathf.RoundToInt(corners[0].x);
|
||||
int y = Mathf.RoundToInt(Screen.height - corners[1].y); // Unity 左下原点 -> Win32 左上原点
|
||||
int width = Mathf.RoundToInt(panel.rect.width);
|
||||
int height = Mathf.RoundToInt(panel.rect.height);
|
||||
|
||||
ProcessStartInfo psi = new ProcessStartInfo(hostPath);
|
||||
psi.Arguments = $"{x} {y} {width} {height} \"{h5Path}\"";
|
||||
Process.Start(psi);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user