超大量的更新 修复很多问题,gameplay特效初步

This commit is contained in:
2026-02-14 23:46:20 +08:00
parent ef8eb67259
commit 3a7a0b4669
360 changed files with 85670 additions and 4144 deletions
+28 -28
View File
@@ -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();
@@ -1,9 +1,9 @@
using UnityEngine;
using UnityEngine;
public class WebViewPanelFollower : MonoBehaviour
{
public RectTransform panelRect; // קҪ UI Panel RectTransform
public Camera uiCamera; // UI ͨ Canvas Event Camera
public RectTransform panelRect; // Documentation text normalized.
public Camera uiCamera; // Documentation text normalized.
private Rect lastPanelRect;
private WebViewWin32.RECT lastUnityWindowRect;
@@ -43,17 +43,17 @@ public class WebViewPanelFollower : MonoBehaviour
if (panelRect == null || uiCamera == null || WebViewLauncher.Instance == null)
return;
// ȡǰ panel Ļ
// Documentation text normalized.
Rect currentPanelRect = GetPanelScreenRect(panelRect);
// ȡǰ Unity λã build Ҫ
// Documentation text normalized.
#if !UNITY_EDITOR
WebViewWin32.RECT currentUnityWindowRect = new WebViewWin32.RECT();
if (!WebViewWin32.TryGetClientScreenRect(System.Diagnostics.Process.GetCurrentProcess(), out currentUnityWindowRect))
return;
#endif
// ǷҪ
// Update position when first initialized, panel rect changed, or window rect changed.
if (!hasLastRect ||
!ApproximatelyEqual(currentPanelRect, lastPanelRect)
#if !UNITY_EDITOR
@@ -63,18 +63,16 @@ public class WebViewPanelFollower : MonoBehaviour
{
int x, y;
#if UNITY_EDITOR
// ڱ༭УֱʹĻĻϽǣ
x = Mathf.RoundToInt(currentPanelRect.x);
y = Mathf.RoundToInt(Screen.height - currentPanelRect.y - currentPanelRect.height);
#else
// build Уʹ Unity λ +
x = Mathf.RoundToInt(currentUnityWindowRect.Left + currentPanelRect.x);
y = Mathf.RoundToInt(currentUnityWindowRect.Top + (Screen.height - currentPanelRect.y - currentPanelRect.height));
#endif
int w = Mathf.RoundToInt(currentPanelRect.width);
int h = Mathf.RoundToInt(currentPanelRect.height);
// WebView
// Documentation text normalized.
bool success = WebViewLauncher.Instance.TryUpdateWebViewRect(x, y, w, h);
if (success)
{
+4 -4
View File
@@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using UnityEngine;
@@ -214,9 +214,9 @@ public static class WebViewWin32
}
/// <summary>
/// 尝试向指定进程的主窗口发送 WM_COPYDATA 消息,lParam 为包含 Unicode 字符串的 COPYDATASTRUCT。
/// 接收方需要处理 WM_COPYDATA 并解释字符串为 URL 并导航。
/// 返回 true 表示接收方可能已处理(基于 SendMessage 返回值),false 表示发送或接收未成功。
/// Documentation text normalized.
/// Documentation text normalized.
/// Documentation text normalized.
/// </summary>
public static bool TrySendUrlToWindow(Process process, string url)
{
@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System;
@@ -6,7 +6,7 @@ using System.IO;
public class game_card_Prefab : MonoBehaviour, IPointerClickHandler
{
[Header("PrefabϢ")]
[Header("Inspector")]
public Image card_icon_image;
public Text card_name_text;
public Text authorName_text;
@@ -19,11 +19,10 @@ public class game_card_Prefab : MonoBehaviour, IPointerClickHandler
[Header("Optional clickable Button (auto-find if null)")]
public Button clickButton;
// Ӧ index.html ı· file:// ǰ׺
// Documentation text normalized.
private string indexFilePath;
// loadLittleGamesPrefab ı·
public void SetData(string indexPath, string cardName, string authorName, string description, string isOfficial, string source, string yyyyMmDd, string version = null)
public void SetData(string indexPath, string cardName, string authorName, string description, string isOfficial, string source, string yyyyMmDd, string version)
{
indexFilePath = indexPath;
if (card_name_text != null) card_name_text.text = cardName ?? "";
@@ -96,7 +95,7 @@ public class game_card_Prefab : MonoBehaviour, IPointerClickHandler
OpenIndexPath();
}
// ʱͨ WebViewLauncher 򿪶Ӧ index.html
// Documentation text normalized.
public void OnPointerClick(PointerEventData eventData)
{
UnityEngine.Debug.Log($"game_card_Prefab.OnPointerClick: indexPath='{indexFilePath}'");
@@ -111,7 +110,7 @@ public class game_card_Prefab : MonoBehaviour, IPointerClickHandler
return;
}
// ʹ WebViewLauncher
// Documentation text normalized.
if (WebViewLauncher.Instance != null)
{
UnityEngine.Debug.Log("Calling WebViewLauncher.OpenUrl with: " + indexFilePath);
@@ -135,7 +134,7 @@ public class game_card_Prefab : MonoBehaviour, IPointerClickHandler
else
{
UnityEngine.Debug.LogWarning("WebViewLauncher instance not found. Attempting to start new launcher.");
// Բҳе WebViewLauncher 򴴽һµ GameObject
// Documentation text normalized.
var launcherObj = UnityEngine.Object.FindAnyObjectByType<WebViewLauncher>();
if (launcherObj != null)
{
@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using UnityEngine.UI;
using System.IO;
using System.Collections.Generic;
@@ -14,11 +14,11 @@ public class loadLittleGamesPrefab : MonoBehaviour
[Header("Prefab")]
public GameObject littleGames_card_Prefab;
[Tooltip("Ĭiconͼ")]
[Tooltip("Documentation text normalized.")]
public Sprite default_card_icon_sprite;
[Header("Refresh")]
public Button refreshButton; // ɨ貢ˢб
public Button refreshButton; // Documentation text normalized.
[Header("H5 Root Path (optional, leave empty to use WebViewLauncher settings)")]
public string h5RootPath;
@@ -108,11 +108,11 @@ public class loadLittleGamesPrefab : MonoBehaviour
continue;
// defaults
string defName = "δ֪Htmlļ";
string defAuthor = "δ֪";
string defDesc = "Ϣ";
string defIsOfficial = "δ֪Դ";
string defSource = "Զ";
string defName = "Unknown HTML Page";
string defAuthor = "Unknown Author";
string defDesc = "No description provided.";
string defIsOfficial = "Unknown Source";
string defSource = "Unknown";
string defDateRaw = "19700101";
string cardName = GetMeta(meta, "card_name") ?? defName;
@@ -128,12 +128,12 @@ public class loadLittleGamesPrefab : MonoBehaviour
if (cat == "_officialDocs" || cat == "_officialGames")
{
isOfficial = "ٷ";
source = "СϷDLC";
isOfficial = "Official";
source = "MiniGame DLC";
}
else
{
if (string.IsNullOrEmpty(isOfficial)) isOfficial = "Դ";
if (string.IsNullOrEmpty(isOfficial)) isOfficial = "Community";
if (string.IsNullOrEmpty(source)) source = defSource;
}