Skip to content

Commit

Permalink
updated to v2.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
michael811125 committed May 11, 2024
1 parent 77ee4e2 commit abdee9b
Show file tree
Hide file tree
Showing 64 changed files with 965 additions and 259 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,29 @@ internal interface IDecryptStream
Stream DecryptStream(DecryptFileInfo fileInfo);
}

public class NoneDecryption : IDecryptionServices, IDecryptStream
internal interface IDecryptData
{
byte[] DecryptData(DecryptFileInfo fileInfo);
}

public class NoneDecryption : IDecryptionServices, IDecryptStream, IDecryptData
{
#region OxGFrame Implements
public byte[] DecryptData(DecryptFileInfo fileInfo)
{
string filePath = fileInfo.FileLoadPath;
if (File.Exists(filePath) == false)
return null;
return File.ReadAllBytes(filePath);
}

public Stream DecryptStream(DecryptFileInfo fileInfo)
{
string filePath = fileInfo.FileLoadPath;
var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.None);
return fs;
}
#endregion

public uint GetManagedReadBufferSize()
{
Expand All @@ -35,17 +50,37 @@ public AssetBundleCreateRequest LoadAssetBundleAsync(DecryptFileInfo fileInfo, o
managedStream = this.DecryptStream(fileInfo);
return AssetBundle.LoadFromStreamAsync(managedStream, fileInfo.ConentCRC, GetManagedReadBufferSize());
}

public byte[] LoadRawFileData(DecryptFileInfo fileInfo)
{
return this.DecryptData(fileInfo);
}
}

public class OffsetDecryption : IDecryptionServices, IDecryptStream
public class OffsetDecryption : IDecryptionServices, IDecryptStream, IDecryptData
{
#region OxGFrame Implements
public byte[] DecryptData(DecryptFileInfo fileInfo)
{
OxGFrame.AssetLoader.Utility.SecureMemory.SecureString[] decryptArgs = BundleConfig.decryptArgs;
string filePath = fileInfo.FileLoadPath;
int dummySize = Convert.ToInt32(decryptArgs[1].Decrypt());
if (File.Exists(filePath) == false)
return null;
byte[] data = File.ReadAllBytes(filePath);
if (FileCryptogram.Offset.OffsetDecryptBytes(ref data, dummySize))
return data;
return null;
}

public Stream DecryptStream(DecryptFileInfo fileInfo)
{
OxGFrame.AssetLoader.Utility.SecureMemory.SecureString[] decryptArgs = BundleConfig.decryptArgs;
string filePath = fileInfo.FileLoadPath;
int dummySize = Convert.ToInt32(decryptArgs[1].Decrypt());
return FileCryptogram.Offset.OffsetDecryptStream(filePath, dummySize);
}
#endregion

public uint GetManagedReadBufferSize()
{
Expand All @@ -63,17 +98,37 @@ public AssetBundleCreateRequest LoadAssetBundleAsync(DecryptFileInfo fileInfo, o
managedStream = this.DecryptStream(fileInfo);
return AssetBundle.LoadFromStreamAsync(managedStream, fileInfo.ConentCRC, GetManagedReadBufferSize());
}

public byte[] LoadRawFileData(DecryptFileInfo fileInfo)
{
return this.DecryptData(fileInfo);
}
}

public class XorDecryption : IDecryptionServices, IDecryptStream
public class XorDecryption : IDecryptionServices, IDecryptStream, IDecryptData
{
#region OxGFrame Implements
public byte[] DecryptData(DecryptFileInfo fileInfo)
{
OxGFrame.AssetLoader.Utility.SecureMemory.SecureString[] decryptArgs = BundleConfig.decryptArgs;
string filePath = fileInfo.FileLoadPath;
byte xorKey = Convert.ToByte(decryptArgs[1].Decrypt());
if (File.Exists(filePath) == false)
return null;
byte[] data = File.ReadAllBytes(filePath);
if (FileCryptogram.XOR.XorDecryptBytes(data, xorKey))
return data;
return null;
}

public Stream DecryptStream(DecryptFileInfo fileInfo)
{
OxGFrame.AssetLoader.Utility.SecureMemory.SecureString[] decryptArgs = BundleConfig.decryptArgs;
string filePath = fileInfo.FileLoadPath;
byte xorKey = Convert.ToByte(decryptArgs[1].Decrypt());
return FileCryptogram.XOR.XorDecryptStream(filePath, xorKey);
}
#endregion

public uint GetManagedReadBufferSize()
{
Expand All @@ -91,10 +146,31 @@ public AssetBundleCreateRequest LoadAssetBundleAsync(DecryptFileInfo fileInfo, o
managedStream = this.DecryptStream(fileInfo);
return AssetBundle.LoadFromStreamAsync(managedStream, fileInfo.ConentCRC, GetManagedReadBufferSize());
}

public byte[] LoadRawFileData(DecryptFileInfo fileInfo)
{
return this.DecryptData(fileInfo);
}
}

public class HT2XorDecryption : IDecryptionServices, IDecryptStream
public class HT2XorDecryption : IDecryptionServices, IDecryptStream, IDecryptData
{
#region OxGFrame Implements
public byte[] DecryptData(DecryptFileInfo fileInfo)
{
OxGFrame.AssetLoader.Utility.SecureMemory.SecureString[] decryptArgs = BundleConfig.decryptArgs;
string filePath = fileInfo.FileLoadPath;
byte hXorkey = Convert.ToByte(decryptArgs[1].Decrypt());
byte tXorkey = Convert.ToByte(decryptArgs[2].Decrypt());
byte jXorKey = Convert.ToByte(decryptArgs[3].Decrypt());
if (File.Exists(filePath) == false)
return null;
byte[] data = File.ReadAllBytes(filePath);
if (FileCryptogram.HT2XOR.HT2XorDecryptBytes(data, hXorkey, tXorkey, jXorKey))
return data;
return null;
}

public Stream DecryptStream(DecryptFileInfo fileInfo)
{
OxGFrame.AssetLoader.Utility.SecureMemory.SecureString[] decryptArgs = BundleConfig.decryptArgs;
Expand All @@ -104,6 +180,7 @@ public Stream DecryptStream(DecryptFileInfo fileInfo)
byte jXorKey = Convert.ToByte(decryptArgs[3].Decrypt());
return FileCryptogram.HT2XOR.HT2XorDecryptStream(filePath, hXorkey, tXorkey, jXorKey);
}
#endregion

public uint GetManagedReadBufferSize()
{
Expand All @@ -121,10 +198,30 @@ public AssetBundleCreateRequest LoadAssetBundleAsync(DecryptFileInfo fileInfo, o
managedStream = this.DecryptStream(fileInfo);
return AssetBundle.LoadFromStreamAsync(managedStream, fileInfo.ConentCRC, GetManagedReadBufferSize());
}

public byte[] LoadRawFileData(DecryptFileInfo fileInfo)
{
return this.DecryptData(fileInfo);
}
}

public class AesDecryption : IDecryptionServices, IDecryptStream
public class AesDecryption : IDecryptionServices, IDecryptStream, IDecryptData
{
#region OxGFrame Implements
public byte[] DecryptData(DecryptFileInfo fileInfo)
{
OxGFrame.AssetLoader.Utility.SecureMemory.SecureString[] decryptArgs = BundleConfig.decryptArgs;
string filePath = fileInfo.FileLoadPath;
string aesKey = decryptArgs[1].Decrypt();
string aesIv = decryptArgs[2].Decrypt();
if (File.Exists(filePath) == false)
return null;
byte[] data = File.ReadAllBytes(filePath);
if (FileCryptogram.AES.AesDecryptBytes(data, aesKey, aesIv))
return data;
return null;
}

public Stream DecryptStream(DecryptFileInfo fileInfo)
{
OxGFrame.AssetLoader.Utility.SecureMemory.SecureString[] decryptArgs = BundleConfig.decryptArgs;
Expand All @@ -133,6 +230,7 @@ public Stream DecryptStream(DecryptFileInfo fileInfo)
string aesIv = decryptArgs[2].Decrypt();
return FileCryptogram.AES.AesDecryptStream(filePath, aesKey, aesIv);
}
#endregion

public uint GetManagedReadBufferSize()
{
Expand All @@ -150,5 +248,10 @@ public AssetBundleCreateRequest LoadAssetBundleAsync(DecryptFileInfo fileInfo, o
managedStream = this.DecryptStream(fileInfo);
return AssetBundle.LoadFromStreamAsync(managedStream, fileInfo.ConentCRC, GetManagedReadBufferSize());
}

public byte[] LoadRawFileData(DecryptFileInfo fileInfo)
{
return this.DecryptData(fileInfo);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public static string[] GetDriveNames()
/// </summary>
/// <returns>The available space in MB.</returns>
public static int CheckAvailableSpace(){
DriveInfo drive = GetDrive (DEFAULT_DRIVE);
DriveInfo drive = new DriveInfo(DEFAULT_DRIVE);
if (drive == null)
return -1;
return int.Parse((drive.AvailableFreeSpace / MEGA_BYTE).ToString());
Expand All @@ -152,7 +152,7 @@ public static string[] GetDriveNames()
/// </summary>
/// <returns>The total space in MB.</returns>
public static int CheckTotalSpace(){
DriveInfo drive = GetDrive (DEFAULT_DRIVE);
DriveInfo drive = new DriveInfo(DEFAULT_DRIVE);
if (drive == null)
return -1;
return int.Parse ((drive.TotalSize / MEGA_BYTE).ToString());
Expand All @@ -163,7 +163,7 @@ public static string[] GetDriveNames()
/// </summary>
/// <returns>The busy space in MB.</returns>
public static int CheckBusySpace(){
DriveInfo drive = GetDrive (DEFAULT_DRIVE);
DriveInfo drive = new DriveInfo(DEFAULT_DRIVE);
if (drive == null)
return -1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace YooAsset.Editor
public static class AssetBundleBuilderHelper
{
/// <summary>
/// 获取默认的输出根路录
/// 获取默认的输出根目录
/// </summary>
public static string GetDefaultBuildOutputRoot()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected void CreateReportFile(BuildParametersContext buildParametersContext, B
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
buildReport.Summary.IgnoreDefaultType = buildMapContext.Command.IgnoreDefaultType;
buildReport.Summary.IgnoreRuleName = buildMapContext.Command.IgnoreRule.GetType().FullName;
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;

// 构建参数
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ public class BuiltinBuildPipeline : IBuildPipeline
{
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
{
AssetBundleBuilder builder = new AssetBundleBuilder();
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
if (buildParameters is BuiltinBuildParameters)
{
AssetBundleBuilder builder = new AssetBundleBuilder();
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
}
else
{
throw new Exception($"Invalid build parameter type : {buildParameters.GetType().Name}");
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Linq;
using System.IO;
using System.Collections;
using System.Collections.Generic;

namespace YooAsset.Editor
{
public class TaskEncryption_RFBP : TaskEncryption, IBuildTask
{
void IBuildTask.Run(BuildContext context)
{
var buildParameters = context.GetContextObject<BuildParametersContext>();
var buildMapContext = context.GetContextObject<BuildMapContext>();

var buildMode = buildParameters.Parameters.BuildMode;
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
{
EncryptingBundleFiles(buildParameters, buildMapContext);
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ public class RawFileBuildPipeline : IBuildPipeline
{
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
{
AssetBundleBuilder builder = new AssetBundleBuilder();
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
if (buildParameters is RawFileBuildParameters)
{
AssetBundleBuilder builder = new AssetBundleBuilder();
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
}
else
{
throw new Exception($"Invalid build parameter type : {buildParameters.GetType().Name}");
}
}

/// <summary>
Expand All @@ -25,6 +32,7 @@ private List<IBuildTask> GetDefaultBuildPipeline()
new TaskPrepare_RFBP(),
new TaskGetBuildMap_RFBP(),
new TaskBuilding_RFBP(),
new TaskEncryption_RFBP(),
new TaskUpdateBundleInfo_RFBP(),
new TaskCreateManifest_RFBP(),
new TaskCreateReport_RFBP(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static IList<IBuildTask> Create(string builtInShaderBundleName)
#endif
buildTasks.Add(new CalculateAssetDependencyData());
buildTasks.Add(new StripUnusedSpriteSources());
buildTasks.Add(new CreateBuiltInShadersBundle(builtInShaderBundleName));
buildTasks.Add(new CreateBuiltInBundle(builtInShaderBundleName));
buildTasks.Add(new PostDependencyCallback());

// Packing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ public class ScriptableBuildPipeline : IBuildPipeline
{
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
{
AssetBundleBuilder builder = new AssetBundleBuilder();
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
if (buildParameters is ScriptableBuildParameters)
{
AssetBundleBuilder builder = new AssetBundleBuilder();
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
}
else
{
throw new Exception($"Invalid build parameter type : {buildParameters.GetType().Name}");
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_2019_4_OR_NEWER
#if UNITY_2019_4_OR_NEWER
using System;
using System.IO;
using System.Linq;
Expand All @@ -18,7 +18,7 @@ public BuiltinBuildPipelineViewer(string packageName, BuildTarget buildTarget, V
}

/// <summary>
/// Ö´Ðй¹½¨
/// 执行构建
/// </summary>
protected override void ExecuteBuild()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_2019_4_OR_NEWER
#if UNITY_2019_4_OR_NEWER
using System;
using System.IO;
using System.Linq;
Expand All @@ -20,7 +20,7 @@ public RawfileBuildpipelineViewer(string packageName, BuildTarget buildTarget, V
}

/// <summary>
/// Ö´Ðй¹½¨
/// 执行构建
/// </summary>
protected override void ExecuteBuild()
{
Expand Down
Loading

0 comments on commit abdee9b

Please sign in to comment.