超大量的更新 修复很多问题,gameplay特效初步
This commit is contained in:
@@ -33,19 +33,19 @@ public class WebViewLauncher : MonoBehaviour
|
||||
public event Action WebViewReady;
|
||||
|
||||
[Header("Control Buttons (optional)")]
|
||||
public Button refreshButton; // 刷新当前webview页面
|
||||
public Button closeButton; // 关闭webview
|
||||
public Button restartButton; // 重启webview
|
||||
public Button backButton; // 返回
|
||||
public Button forwardButton; // 前进
|
||||
public Button startRestartButton; // 新增:根据运行状态启动或重启 webview2
|
||||
public Button forceKillButton; // 强制结束进程按钮
|
||||
public Button hideWindowButton; // 隐藏webview窗口
|
||||
public Button showWindowButton; // 显示webview窗口
|
||||
public Button toggleTextButton; // 新增:控制文本显示/隐藏的按钮
|
||||
public Button refreshButton; // Documentation text normalized.
|
||||
public Button closeButton; // Documentation text normalized.
|
||||
public Button restartButton; // Documentation text normalized.
|
||||
public Button backButton; // Documentation text normalized.
|
||||
public Button forwardButton; // Documentation text normalized.
|
||||
public Button startRestartButton; // Documentation text normalized.
|
||||
public Button forceKillButton; // Documentation text normalized.
|
||||
public Button hideWindowButton; // Documentation text normalized.
|
||||
public Button showWindowButton; // Documentation text normalized.
|
||||
public Button toggleTextButton; // Documentation text normalized.
|
||||
|
||||
[Header("Text to Toggle")]
|
||||
public Text controlText; // 要控制显示/隐藏的文本
|
||||
public Text controlText; // Documentation text normalized.
|
||||
|
||||
[Header("Autostart")]
|
||||
public UnityEngine.UI.Toggle autostartToggle; // UI toggle to control auto-start
|
||||
@@ -53,12 +53,12 @@ public class WebViewLauncher : MonoBehaviour
|
||||
private const string PREF_AUTOSTART = "WebView_AutoStart";
|
||||
|
||||
[Header("Homepage / URL UI")]
|
||||
public Button homepageButton; // 返回主页
|
||||
public InputField urlInputField; // 显示/输入当前 url
|
||||
public Button homepageButton; // Documentation text normalized.
|
||||
public InputField urlInputField; // Documentation text normalized.
|
||||
[Tooltip("Homepage URL (can be file:// or http(s) or local path)")]
|
||||
public string homepageUrl = "";
|
||||
[Header("Go button")]
|
||||
public Button goButton; // 点击跳转,和回车效果一致
|
||||
public Button goButton; // Documentation text normalized.
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@@ -144,12 +144,12 @@ public class WebViewLauncher : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
// 扫描 H5 文件夹
|
||||
// Documentation text normalized.
|
||||
var h5SubFolders = ScanH5Folders(h5Folder);
|
||||
if (h5SubFolders.Count > 0)
|
||||
{
|
||||
Debug.Log("Found H5 folders: " + string.Join(", ", h5SubFolders));
|
||||
string selectedFolder = h5SubFolders[0]; // 选择第一个
|
||||
string selectedFolder = h5SubFolders[0]; // Documentation text normalized.
|
||||
string candidatePath = Path.Combine(h5Folder, selectedFolder, "index.html");
|
||||
startUrl = new Uri(candidatePath).AbsoluteUri; // ensure proper file:/// URI
|
||||
Debug.Log("Selected H5 folder: " + selectedFolder + ", URL: " + startUrl);
|
||||
@@ -257,7 +257,7 @@ public class WebViewLauncher : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
// 初始参数可以给 0,后续由 PanelFollower 接管
|
||||
// Documentation text normalized.
|
||||
string args = $"0 0 800 600 \"{startUrl}\"";
|
||||
|
||||
Debug.Log($"Launching: {exePath} {args}");
|
||||
@@ -266,7 +266,7 @@ public class WebViewLauncher : MonoBehaviour
|
||||
{
|
||||
FileName = exePath,
|
||||
Arguments = args,
|
||||
UseShellExecute = true, // 改为 true 以确保 exe 能启动
|
||||
UseShellExecute = true, // Documentation text normalized.
|
||||
WorkingDirectory = Path.GetDirectoryName(exePath)
|
||||
};
|
||||
|
||||
@@ -318,8 +318,8 @@ public class WebViewLauncher : MonoBehaviour
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从外部请求打开一个 url。如果 webview 没有运行则启动;如果已运行则尝试通过 WM_COPYDATA 发送 url 给已有窗口,失败则重启。
|
||||
/// 传入的 url 建议使用本地文件路径或以 file:// 开头的路径。
|
||||
/// Documentation text normalized.
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
public void OpenUrl(string url)
|
||||
@@ -387,7 +387,7 @@ public class WebViewLauncher : MonoBehaviour
|
||||
}
|
||||
catch { }
|
||||
|
||||
// 尝试通过 WM_COPYDATA 将 URL 发送给已有进程窗口(需要 fdBrowser 实现接收处理)
|
||||
// Documentation text normalized.
|
||||
bool sent = WebViewWin32.TrySendUrlToWindow(webProcess, final);
|
||||
Debug.Log($"TrySendUrlToWindow returned: {sent}");
|
||||
if (sent)
|
||||
@@ -398,7 +398,7 @@ public class WebViewLauncher : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
// 发送失败,退回到重启进程打开 URL 的方式
|
||||
// Documentation text normalized.
|
||||
Debug.Log("Failed to send URL to existing process, restarting to open: " + final);
|
||||
KillWebView();
|
||||
LaunchWebView();
|
||||
@@ -542,7 +542,7 @@ public class WebViewLauncher : MonoBehaviour
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换控制文本的显示/隐藏状态
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
void ToggleTextVisibility()
|
||||
{
|
||||
@@ -580,14 +580,14 @@ public class WebViewLauncher : MonoBehaviour
|
||||
#if UNITY_EDITOR
|
||||
return Path.Combine(editorExeRoot, "fdBrowser.exe");
|
||||
#else
|
||||
// 优先使用 StreamingAssets 路径
|
||||
// Documentation text normalized.
|
||||
string streamingPath = Path.Combine(Application.streamingAssetsPath, "fdBrowser", "fdBrowser.exe");
|
||||
if (File.Exists(streamingPath))
|
||||
{
|
||||
Debug.Log("Using StreamingAssets path: " + streamingPath);
|
||||
return streamingPath;
|
||||
}
|
||||
// 回退到游戏根目录
|
||||
// Documentation text normalized.
|
||||
string gameRoot = Path.GetDirectoryName(Application.dataPath);
|
||||
string fallbackPath = Path.Combine(gameRoot, "fdBrowser", "fdBrowser.exe");
|
||||
Debug.Log("Using fallback path: " + fallbackPath);
|
||||
@@ -642,7 +642,7 @@ public class WebViewLauncher : MonoBehaviour
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给 PanelFollower 调用
|
||||
/// Documentation text normalized.
|
||||
/// </summary>
|
||||
public bool TryUpdateWebViewRect(int x, int y, int w, int h)
|
||||
{
|
||||
@@ -743,7 +743,7 @@ public class WebViewLauncher : MonoBehaviour
|
||||
}
|
||||
catch { }
|
||||
|
||||
// 尝试通过 WM_COPYDATA 将 URL 发送给已有进程窗口(需要 fdBrowser 实现接收处理)
|
||||
// Documentation text normalized.
|
||||
bool sent = WebViewWin32.TrySendUrlToWindow(webProcess, finalUrl);
|
||||
Debug.Log($"TrySendUrlToWindow returned: {sent}");
|
||||
if (sent)
|
||||
@@ -754,7 +754,7 @@ public class WebViewLauncher : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
// 发送失败,退回到重启进程打开 URL 的方式
|
||||
// Documentation text normalized.
|
||||
Debug.Log("Failed to send URL to existing process, restarting to open: " + finalUrl);
|
||||
KillWebView();
|
||||
LaunchWebView();
|
||||
|
||||
Reference in New Issue
Block a user