From f736485f1337e64475d54352fccc460b817c1441 Mon Sep 17 00:00:00 2001 From: hch <305670599@qq.com> Date: 星期六, 11 五月 2024 16:32:05 +0800 Subject: [PATCH] 0312 加密处理 --- Assets/Launch/ResourcesModel.cs | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 44 insertions(+), 5 deletions(-) diff --git a/Assets/Launch/ResourcesModel.cs b/Assets/Launch/ResourcesModel.cs index 67d0978..569c1de 100644 --- a/Assets/Launch/ResourcesModel.cs +++ b/Assets/Launch/ResourcesModel.cs @@ -5,7 +5,7 @@ using LitJsonForAot; using System.Collections; using UnityEngine.Networking; - +using System.Linq; namespace StartAot { @@ -13,7 +13,7 @@ { //涓嶄笅杞芥椂鏈湴瀹夊崜娴嬭瘯璺緞 public string assetBundlesPath { get; private set; } - public static string bytesFolderName = "logicbytes/"; + public static string bytesFolderName = "daimazijie/"; public string StreamingAssetPath { get; private set; } public string ExternalStorePath { get; private set; } @@ -64,7 +64,7 @@ string assetBytesUrl; //浠庣綉缁滆幏鍙栫殑璧勬簮鐗堟湰淇℃伅 public Dictionary<string, AssetVersion> assetVersions = new Dictionary<string, AssetVersion>(); - //鏈湴LogicBytes鏂囦欢鍜� assetVersions 姣旇緝鏄惁闇�瑕佷笅杞� + //鏈湴daimazijie鏂囦欢鍜� assetVersions 姣旇緝鏄惁闇�瑕佷笅杞� public Dictionary<string, AssetVersion> localAssetVersions = new Dictionary<string, AssetVersion>(); public static string versionUrlResult { get; private set; } @@ -230,9 +230,48 @@ } + //灏嗘枃浠跺悕鍊掑簭锛屽姞涓奯aop鍚庣紑 + public string EncodeFileName(string name) + { + name = name.Replace("\\", "/"); + int index = name.LastIndexOf("/"); + string headString; + if (index >= 0) + { + int dotLastIndex = name.LastIndexOf("."); + if (dotLastIndex == -1) + { + headString = name.Substring(0, index); + name = name.Substring(index + 1); + return StringUtility.Contact(headString, "/", new string(name.Reverse().ToArray()), "_aop"); + } + else + { + headString = name.Substring(0, index); + var ext = name.Substring(dotLastIndex); + name = name.Substring(index + 1, dotLastIndex - index - 1); + return StringUtility.Contact(headString, "/", new string(name.Reverse().ToArray()), "_aop", ext); + } + } + else + { + int dotLastIndex = name.LastIndexOf("."); + if (dotLastIndex == -1) + return StringUtility.Contact(new string(name.Reverse().ToArray()), "_aop"); + else + { + var ext = name.Substring(dotLastIndex); + name = name.Substring(0, dotLastIndex); + return StringUtility.Contact(new string(name.Reverse().ToArray()), "_aop", ext); + } + } + + } + public string GetAssetFilePath(string _assetKey) { + _assetKey = EncodeFileName(_assetKey); var path = Path.Combine(ExternalStorePath, _assetKey); if (!File.Exists(path)) { @@ -333,7 +372,7 @@ //LogicBytes鏂囦欢鐨凪D5淇℃伅 public void RequestLogicBytes() { - var remoteURL = string.Concat(versionInfo.GetResourcesURL(VersionConfigEx.Get().branch), fixPath, "/logicbytes.txt"); + var remoteURL = string.Concat(versionInfo.GetResourcesURL(VersionConfigEx.Get().branch), fixPath, "/daimazijie.txt"); //var localURL = string.Concat(.ExternalStorePath, "/logicbytes.txt"); assetBytesUrl = remoteURL; Debug.Log("http鍦板潃:logicbytesUrl " + assetBytesUrl); @@ -434,7 +473,7 @@ if (isPCTestDownLoad || Application.isMobilePlatform) { //璇诲彇鐨勪竴瀹氭槸StreamingAssetPath璺緞 - StartCoroutine(ReadText("logicbytes", (isOK, value) => + StartCoroutine(ReadText("daimazijie", (isOK, value) => { if (isOK) InitLocalLogicbytes(value); -- Gitblit v1.8.0