25 lines
882 B
C#
25 lines
882 B
C#
using System.Diagnostics;
|
|
using UnityEngine;
|
|
|
|
public class LaunchH5 : MonoBehaviour
|
|
{
|
|
public RectTransform panel; // Documentation text normalized.
|
|
public string hostPath = "WebView2Host/WebView2Host.exe"; // Documentation text normalized.
|
|
|
|
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); // Documentation text normalized.
|
|
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);
|
|
}
|
|
}
|