-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat][editor]:增加移除补丁资源依赖列表中的非补丁资源,防止资源在内存中冗余
- Loading branch information
1 parent
ffe7159
commit 020bd28
Showing
4 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
Assets/CatAsset/Editor/BuildPipeline/Task/RemoveNonPatchDependency.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.Collections.Generic; | ||
using CatAsset.Runtime; | ||
using UnityEditor.Build.Pipeline; | ||
using UnityEditor.Build.Pipeline.Injector; | ||
using UnityEditor.Build.Pipeline.Interfaces; | ||
using UnityEngine; | ||
|
||
namespace CatAsset.Editor | ||
{ | ||
/// <summary> | ||
/// 移除非补丁资源的依赖,以防止资源内存冗余 | ||
/// </summary> | ||
public class RemoveNonPatchDependency : IBuildTask | ||
{ | ||
public int Version { get; } | ||
|
||
[InjectContext(ContextUsage.In)] | ||
private IManifestParam manifestParam; | ||
|
||
public ReturnCode Run() | ||
{ | ||
HashSet<string> patchAssets = new HashSet<string>(); | ||
foreach (BundleManifestInfo bundleManifestInfo in manifestParam.Manifest.Bundles) | ||
{ | ||
foreach (AssetManifestInfo assetManifestInfo in bundleManifestInfo.Assets) | ||
{ | ||
patchAssets.Add(assetManifestInfo.Name); | ||
} | ||
} | ||
|
||
foreach (BundleManifestInfo bundleManifestInfo in manifestParam.Manifest.Bundles) | ||
{ | ||
foreach (AssetManifestInfo assetManifestInfo in bundleManifestInfo.Assets) | ||
{ | ||
for (int i = assetManifestInfo.Dependencies.Count - 1; i >= 0; i--) | ||
{ | ||
string dependency = assetManifestInfo.Dependencies[i]; | ||
if (!patchAssets.Contains(dependency)) | ||
{ | ||
assetManifestInfo.Dependencies.RemoveAt(i); | ||
Debug.Log($"移除{assetManifestInfo}的依赖列表中的非补丁资源{dependency}"); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return ReturnCode.Success; | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Assets/CatAsset/Editor/BuildPipeline/Task/RemoveNonPatchDependency.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.