From 3de632f8119498cb0324925fc738292b16840d13 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Fri, 28 Mar 2025 08:48:11 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9web=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=8A=A0=E8=BD=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ResKit/Scripts/Framework/ResSearchKeys.cs | 32 +++++++++++++------ Assets/Scripts/Actions/TimeLineAction.cs | 2 -- Assets/Scripts/Editor/VirtualFPostProcess.cs | 16 ++++++---- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/Assets/QFramework/Toolkits/ResKit/Scripts/Framework/ResSearchKeys.cs b/Assets/QFramework/Toolkits/ResKit/Scripts/Framework/ResSearchKeys.cs index 52bddbcd..6fdcd361 100644 --- a/Assets/QFramework/Toolkits/ResKit/Scripts/Framework/ResSearchKeys.cs +++ b/Assets/QFramework/Toolkits/ResKit/Scripts/Framework/ResSearchKeys.cs @@ -7,30 +7,44 @@ ****************************************************************************/ using System; +using System.Diagnostics; namespace QFramework { - public class ResSearchKeys : IPoolable,IPoolType - { + public class ResSearchKeys : IPoolable, IPoolType + { public string AssetName { get; set; } - public string OwnerBundle { get; set; } + public string OwnerBundle { get; set; } public Type AssetType { get; set; } public string OriginalAssetName { get; set; } - - + + public static ResSearchKeys Allocate(string assetName, string ownerBundleName = null, Type assetType = null) { var resSearchRule = SafeObjectPool.Instance.Allocate(); - resSearchRule.AssetName = assetName.ToLower(); + + if (assetName.Contains("netimage:") || + assetName.Contains("localimage:") || + assetName.Contains("localaudio:") || + assetName.Contains("localtext:") || + assetName.Contains("localbytes:")) + { + // ʱд + resSearchRule.AssetName = assetName; + } + else + { + resSearchRule.AssetName = assetName.ToLower(); + } resSearchRule.OwnerBundle = ownerBundleName == null ? null : ownerBundleName.ToLower(); resSearchRule.AssetType = assetType; resSearchRule.OriginalAssetName = assetName; return resSearchRule; } - + public void Recycle2Cache() { SafeObjectPool.Instance.Recycle(this); @@ -51,10 +65,10 @@ namespace QFramework { isMatch = isMatch && res.OwnerBundleName == OwnerBundle; } - + return isMatch; } - + return false; } diff --git a/Assets/Scripts/Actions/TimeLineAction.cs b/Assets/Scripts/Actions/TimeLineAction.cs index 505746e4..919ffb26 100644 --- a/Assets/Scripts/Actions/TimeLineAction.cs +++ b/Assets/Scripts/Actions/TimeLineAction.cs @@ -60,7 +60,6 @@ public class TimeLineAction : IAction public void OnExecute(float dt) { - Debug.LogError($"time:{play.time * fps} >= curEnd:{curEndFrame} "); if (curEndFrame != -1 && play.time * fps >= curEndFrame) { play.time = curEndFrame / 24; @@ -69,7 +68,6 @@ public class TimeLineAction : IAction } if (play.state != PlayState.Playing) { - Debug.LogError("Finished"); Finished(); } } diff --git a/Assets/Scripts/Editor/VirtualFPostProcess.cs b/Assets/Scripts/Editor/VirtualFPostProcess.cs index 41b0b061..37b625a1 100644 --- a/Assets/Scripts/Editor/VirtualFPostProcess.cs +++ b/Assets/Scripts/Editor/VirtualFPostProcess.cs @@ -18,7 +18,7 @@ public class VirtualFPostProcess : IPostprocessBuildWithReport if (Directory.Exists(dataFolderPath)) { // ĿĿ¼ǿСд - string targetDataPath = Path.Combine(buildOutputPath, "data"); + string targetDataPath = Path.Combine(buildOutputPath, "Data"); CopyDirectoryWithLowerCaseNames(dataFolderPath, targetDataPath); Debug.Log($"Ŀ¼ѸƵ: {targetDataPath}"); } @@ -41,23 +41,25 @@ public class VirtualFPostProcess : IPostprocessBuildWithReport private void CopyDirectoryWithLowerCaseNames(string sourceDir, string targetDir) { // СдĿĿ¼ - var lowerTargetDir = ConvertToLowerPath(targetDir); - Directory.CreateDirectory(lowerTargetDir); + //var lowerTargetDir = ConvertToLowerPath(targetDir); + Directory.CreateDirectory(targetDir); // ļСдת foreach (var file in Directory.GetFiles(sourceDir)) { string fileName = Path.GetFileName(file); - string lowerName = ConvertToLowerPath(fileName); - File.Copy(file, Path.Combine(lowerTargetDir, lowerName), true); + // ʱСдת + //string lowerName = ConvertToLowerPath(fileName); + File.Copy(file, Path.Combine(targetDir, fileName), true); } // ݹ鴦Ŀ¼Сдת foreach (var dir in Directory.GetDirectories(sourceDir)) { string dirName = Path.GetFileName(dir); - string lowerDirName = ConvertToLowerPath(dirName); - CopyDirectoryWithLowerCaseNames(dir, Path.Combine(lowerTargetDir, lowerDirName)); + // ʱСдת + //string lowerDirName = ConvertToLowerPath(dirName); + CopyDirectoryWithLowerCaseNames(dir, Path.Combine(targetDir, dirName)); } } From a49daf71cf967bc107fd2ba3e2a1a4918840af13 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Fri, 28 Mar 2025 09:37:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=93=E5=8C=85?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=88=A0=E9=99=A4=E9=9D=9E=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E7=9A=84=E8=B5=84=E6=BA=90=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Editor/VirtualFPostProcess.cs | 68 ++++++++++++++++++++ Assets/Scripts/Global/Global.cs | 5 +- 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Editor/VirtualFPostProcess.cs b/Assets/Scripts/Editor/VirtualFPostProcess.cs index 37b625a1..a687e3f0 100644 --- a/Assets/Scripts/Editor/VirtualFPostProcess.cs +++ b/Assets/Scripts/Editor/VirtualFPostProcess.cs @@ -1,6 +1,8 @@ +using System; using System.Collections; using System.Collections.Generic; using System.IO; +using UnityEditor; using UnityEditor.Build; using UnityEditor.Build.Reporting; using UnityEngine; @@ -26,6 +28,72 @@ public class VirtualFPostProcess : IPostprocessBuildWithReport { Debug.LogWarning("δҵĿ¼: " + dataFolderPath); } + DeletAssetBundle(buildOutputPath); + } + + /// + /// ɾڵǰƽ̨Դ + /// + public void DeletAssetBundle(string buildOutPutPath) + { + if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.WebGL) + { + string path = Path.Combine(buildOutPutPath, "StreamingAssets", "AssetBundles"); + if (Directory.Exists(path)) + { + string[] allDirectories = Directory.GetDirectories(path); + foreach (string dir in allDirectories) + { + string dirName = Path.GetFileName(dir); + if (!dirName.Equals("WebGL", StringComparison.OrdinalIgnoreCase)) // ԴСд + { + try + { + Directory.Delete(dir, true); + Debug.Log($"Deleted directory: {dir}"); + } + catch (Exception e) + { + Debug.LogError($"Failed to delete {dir}: {e.Message}"); + } + } + } + } + else + { + Debug.LogError($"Directory not found: {path}"); + } + } + else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows|| EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64) + { + string path = Path.Combine(buildOutPutPath, "VirtualFramwork_Data", "StreamingAssets", "AssetBundles"); + if (Directory.Exists(path)) + { + string[] allDirectories = Directory.GetDirectories(path); + foreach (string dir in allDirectories) + { + string dirName = Path.GetFileName(dir); + if (!dirName.Equals("Windows", StringComparison.OrdinalIgnoreCase)) // ԴСд + { + try + { + Directory.Delete(dir, true); + Debug.Log($"Deleted directory: {dir}"); + } + catch (Exception e) + { + Debug.LogError($"Failed to delete {dir}: {e.Message}"); + } + } + } + } + else + { + Debug.LogError($"Directory not found: {path}"); + } + } + + } private string GetValidBuildPath(BuildReport report) diff --git a/Assets/Scripts/Global/Global.cs b/Assets/Scripts/Global/Global.cs index fe5f2b56..808c8902 100644 --- a/Assets/Scripts/Global/Global.cs +++ b/Assets/Scripts/Global/Global.cs @@ -13,8 +13,11 @@ public class Global : Singleton public XMLTool.AppData appData; public Module curModule; public Body3D.Body cur3DPart; - +#if UNITY_WEBGL + public static string dataPath = Application.dataPath + "/Data"; +#else public static string dataPath = Application.dataPath + "/../Data"; +#endif public static string deviceIconsPath = dataPath + "/DeviceIcons/"; public static string audioPath = dataPath + "/Audio/"; public static string appXmlPath = dataPath + "/App.xml";