资源加密添加,防止使用工具获得资源
parent
fbf7c3b41d
commit
700f396a6b
|
@ -476,7 +476,7 @@ namespace AssetBundleBrowser
|
|||
if (null == bundle)
|
||||
{
|
||||
// Load the bundle
|
||||
bundle = AssetBundle.LoadFromFile(path);
|
||||
bundle = AssetBundle.LoadFromFile(path, 0, 128);
|
||||
if (null == bundle)
|
||||
{
|
||||
return null;
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace GameLogic {
|
|||
string url = Util.DataPath + bundleName.ToLower();
|
||||
if (File.Exists(url))
|
||||
{
|
||||
AssetBundle bundle = AssetBundle.LoadFromFile(url);
|
||||
AssetBundle bundle = AssetBundle.LoadFromFile(url, 0, 128);
|
||||
if (bundle != null)
|
||||
{
|
||||
bundleName = bundleName.Replace("lua/", "").Replace(".unity3d", "");
|
||||
|
|
|
@ -369,7 +369,7 @@ namespace ResMgr
|
|||
XNCSUtils.BeginSample("LoadAssetBundle:{0}",path);
|
||||
#endif
|
||||
//assetBundle = AssetBundle.LoadFromMemory(XXTEA.Decrypt(File.ReadAllBytes(fullPath)));
|
||||
assetBundle = AssetBundle.LoadFromFile(fullPath);
|
||||
assetBundle = AssetBundle.LoadFromFile(fullPath, 0, 128);
|
||||
#if XNCS
|
||||
XNCSUtils.EndSample();
|
||||
#endif
|
||||
|
@ -397,7 +397,7 @@ namespace ResMgr
|
|||
{
|
||||
if (BaseLogger.isDebug) BaseLogger.LogFormat("<color=#00FF00>LoadAssetBundleAsyn:{0}</color>", path);
|
||||
abLoaderState = ABLoaderState.Loading;
|
||||
AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(fullPath);
|
||||
AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(fullPath, 0, 128);
|
||||
//AssetBundleCreateRequest request = AssetBundle.LoadFromMemoryAsync(XXTEA.Decrypt(File.ReadAllBytes(fullPath)));
|
||||
while (!request.isDone)
|
||||
{
|
||||
|
|
|
@ -164,7 +164,7 @@ namespace ResMgr
|
|||
{
|
||||
string path = string.Format("LZMA/ResConfigs").ToLower() + ResConfig.ABExtName;
|
||||
string fullPath = PathHelper.GetFullPath (path);
|
||||
AssetBundle ab = AssetBundle.LoadFromFile(fullPath);
|
||||
AssetBundle ab = AssetBundle.LoadFromFile(fullPath, 0, 128);
|
||||
//AssetBundle ab = AssetBundle.LoadFromMemory(XXTEA.Decrypt(File.ReadAllBytes(fullPath)));
|
||||
ResPathConfig = ab.LoadAsset<ResourcePathConfig>("ResourcePathConfig");
|
||||
ab.Unload(true);
|
||||
|
|
|
@ -490,7 +490,7 @@ namespace ResUpdate
|
|||
/// </summary>
|
||||
List<ResourceFile> GetNewResourceFiles()
|
||||
{
|
||||
AssetBundle bundle = AssetBundle.LoadFromFile(UpdateConfigs.PersistentDataPath + UpdateConfigs.FILES);
|
||||
AssetBundle bundle = AssetBundle.LoadFromFile(UpdateConfigs.PersistentDataPath + UpdateConfigs.FILES, 0, 128);
|
||||
ResourceFiles files = bundle.LoadAsset<ResourceFiles>("game");
|
||||
List<ResourceFile> list = files.files;
|
||||
bundle.Unload(true);
|
||||
|
@ -503,7 +503,7 @@ namespace ResUpdate
|
|||
/// <returns></returns>
|
||||
List<ResourceFile> GetStreamResourceFiles()
|
||||
{
|
||||
AssetBundle bundle = AssetBundle.LoadFromFile(UpdateConfigs.StreamPath + UpdateConfigs.FILES);
|
||||
AssetBundle bundle = AssetBundle.LoadFromFile(UpdateConfigs.StreamPath + UpdateConfigs.FILES, 0, 128);
|
||||
if (bundle != null)
|
||||
{
|
||||
ResourceFiles files = bundle.LoadAsset<ResourceFiles>("game");
|
||||
|
|
|
@ -314,7 +314,27 @@ namespace GameEditor.AssetBundle
|
|||
DateTime oldTime = DateTime.Now;
|
||||
AssetBundleBuild[] builds = new AssetBundleBuild[buildMap.Count];
|
||||
buildMap.Values.CopyTo(builds, 0);
|
||||
BuildPipeline.BuildAssetBundles(exportPath, builds, options, buildTarget);
|
||||
var manifest = BuildPipeline.BuildAssetBundles(exportPath, builds, options, buildTarget);
|
||||
|
||||
|
||||
// 加密 文件前加入128个空字符
|
||||
foreach(var name in manifest.GetAllAssetBundles())
|
||||
{
|
||||
var uniqueSalt = Encoding.UTF8.GetBytes(name);
|
||||
string pn = Path.Combine(exportPath, name);
|
||||
byte[] oldData = File.ReadAllBytes(pn);
|
||||
int newOldLen = 128 + oldData.Length;//定死了,128个空byte
|
||||
var newData = new byte[newOldLen];
|
||||
for (int tb = 0; tb < oldData.Length; tb++)
|
||||
{
|
||||
newData[128 + tb] = oldData[tb];
|
||||
}
|
||||
FileStream fs = File.OpenWrite(pn);//打开写入进去
|
||||
fs.Write(newData, 0, newOldLen);
|
||||
fs.Close();
|
||||
}
|
||||
|
||||
|
||||
TimeSpan span = DateTime.Now.Subtract(oldTime);
|
||||
Debug.Log("打包完毕,本次打包耗时:" + span.TotalSeconds + "秒!");
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class GameStart : MonoBehaviour
|
|||
{
|
||||
path = AppConst.StreamPath + "lz4/splashpanel.unity3d";
|
||||
}
|
||||
bundle = AssetBundle.LoadFromFile(path);
|
||||
bundle = AssetBundle.LoadFromFile(path, 0, 128);
|
||||
GameObject gameObj = bundle.LoadAsset<GameObject>("SplashPanel");
|
||||
GameObject gameObj2 = Instantiate(gameObj, Vector3.zero, Quaternion.identity);
|
||||
Image image = gameObj2.transform.Find("Canvas/image").GetComponent<Image>();
|
||||
|
|
|
@ -119,7 +119,7 @@ namespace GameLogic {
|
|||
{
|
||||
path = AppConst.StreamPath + "lz4/updatepanel.unity3d";
|
||||
}
|
||||
bundle = AssetBundle.LoadFromFile(path);
|
||||
bundle = AssetBundle.LoadFromFile(path, 0, 128);
|
||||
if (bundle == null)
|
||||
{
|
||||
XDebug.Log.error(string.Format("{0} 不存在,请检查", path ));
|
||||
|
|
Loading…
Reference in New Issue