untiy清除缓存目录
直接放脚本
因为用的是内嵌网页插件,所以每次都要清除一下内嵌网页浏览器缓存,要不然会导致信息不同步.
导致网页已经更新,项目开启之后网页不会更新.
using System.IO; using UnityEngine; using Vuplex.WebView; public class CacheManager : MonoBehaviour { // 获取 Vuplex 缓存目录 public static string GetVuplexCachePath() { //Debug.Log(Path.Combine(Application.persistentDataPath, "Vuplex.WebView", "chromium-cache", "Cache")); //return Path.Combine(Application.persistentDataPath, "Vuplex.WebView", "chromium-cache", "Cache"); return Path.Combine(Application.persistentDataPath, "Vuplex.WebView", "chromium-cache", "Cache"); } // 启动时清理选项 [SerializeField] private bool clearCacheOnStart = false; void Awake() { if (clearCacheOnStart) { ClearAllCache(); } // 打印路径信息,方便调试 //Debug.Log($"Company Name: {Application.companyName}"); //Debug.Log($"Product Name: {Application.productName}"); Debug.Log($"Persistent Data Path: {Application.persistentDataPath}"); } public void ClearAllCache() { string cachePath = GetVuplexCachePath(); if (Directory.Exists(cachePath)) { try { Directory.Delete(cachePath, true); Debug.Log("Cache cleared successfully"); } catch (System.Exception e) { Debug.LogError($"Failed to clear cache: {e.Message}"); } } // 同时调用 Vuplex 的清理方法 //Web.ClearAllData(); } }
直接运行测试就好

浙公网安备 33010602011771号